What changes can be made to a ship with scripting?

The place to discuss scripting and game modifications for X³: Terran Conflict and X³: Albion Prelude.

Moderators: Moderators for English X Forum, Scripting / Modding Moderators

Post Reply
Firewrath
Posts: 121
Joined: Fri, 3. Aug 07, 05:49
x3tc

What changes can be made to a ship with scripting?

Post by Firewrath » Mon, 21. Nov 11, 08:16

I know, I know, its been asked before, but after searching and trying google, I just cant find it. -_-

I had time to mess with this leveling pilots thing thats been talked about lately and while I understand basic localvars for ships, im kind of at a loss for pilots, So I thought Id look into that, ...not that Im having much luck, but eh. :P

Anyways, Ive Always wanted to convert marines into pilots*, having the marine skills changing things with the ships they fly.
(*How? ...I dont know yet, but if im going to do pilots, this is what Im going to try to do.)


So. Just what can be changed?

Shield regeneration rate?
Maximum weapon energy?
Weapon energy regeneration rate?
Maximum hull amount?
Speed?
Acceleration?
Steering?
Cargo space?

Or any other stat I may have missed? ^-^;

Also, Where do I find these?
All I can find in the MSCI forum/handbook is 'set hull to' and 'set laser energy to' which doesnt change the maximum, only the current.
Then theres 'get current max speed' and 'get max upgraded speed' and again, no 'set max' commands, I cant even find things like 'engine tuning', 'cargo bay expansion', or 'rudder optimization' in the MSCI.

Any help here would be appreciated, I've spent like well over an hour just searching and reading the MSCI. =/

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24965
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Mon, 21. Nov 11, 10:32

Firewrath wrote:All I can find in the MSCI forum/handbook is 'set hull to' and 'set laser energy to' which doesnt change the maximum, only the current.
Only a ship's (maximum) speed and acceleration can be increased via script by installing engine tunings and rudder optimizations using the <RetVar/IF><RefObj> install<Var/Number> units of <Var/Ware>-command.
Firewrath wrote:Then theres 'get current max speed' and 'get max upgraded speed' and again, no 'set max' commands, I cant even find things like 'engine tuning', 'cargo bay expansion', or 'rudder optimization' in the MSCI.
To get the needed amount of engine or rudder optimizations to increase a ship's speed or acceleration to its maximum you have to combine the "<RetVar/IF><RefObj> get max upgrades for upgrade <Var/Ware>"-command and the <RetVar/IF><RefObj> get volume of ware <Var/Ware> in cargo bay-command.

Code: Select all

$max.amount = $ship -> get max upgrades for upgrade $upgrade
$installed.amount = $ship -> get volume of ware $upgrade in cargo bay
$amount = $max.amount - $installed.amount
= $ship -> install $amount units of $upgrade

While you can change the current values for the other things (e.g. set hull or shield to max values) with the Script Editor, you can change the permanent max/min values only by modifying the ship's properties in the TShips file (see the tutorials in the "Tutorials and Resources"-sticky).
Firewrath wrote:Anyways, Ive Always wanted to convert marines into pilots*, having the marine skills changing things with the ships they fly.
(*How? ...I dont know yet, but if im going to do pilots, this is what Im going to try to do.)
Not sure, if that's directly possible. In any case you might want to have a look at the 'Passengers'-command section of the Trade commands.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

Firewrath
Posts: 121
Joined: Fri, 3. Aug 07, 05:49
x3tc

Post by Firewrath » Mon, 21. Nov 11, 15:32

Just want to comment on this Real quick here, i'll look at the other stuff in more detail when i get time later, But for now:
X2-Illuminatus wrote:
Firewrath wrote:Anyways, Ive Always wanted to convert marines into pilots*, having the marine skills changing things with the ships they fly.
(*How? ...I dont know yet, but if im going to do pilots, this is what Im going to try to do.)
Not sure, if that's directly possible. In any case you might want to have a look at the 'Passengers'-command section of the Trade commands.
Yeah, i figured id create a passenger with the same name/race as the marine, then get the marine skills, set them as localvars*, set the new passenger as the ships pilot, and if everything checks out, then somehow remove the marine. Hopefully i can remove/destroy the marine without causing a message to the player,
i havnt Really checked out how well that would work, but thats my theory anyways, >.>
(*while typing this up, it makes me wonder if there is a way to set Passenger localvars, so theyd stay with the passenger instead of the ship.
*hrm* ...i'll have to check that as well, because that would be Very handy,)



As for the ship stats, yeah, i was hoping i could change more with just a script as i dont want to mess with TShips so i can keep compatibility with mods. Seems i never want to do something easy. :P
Thanks for the information on it though, i'll definitely check that out when i have time, ^-^

User avatar
X2-Illuminatus
Moderator (Deutsch)
Moderator (Deutsch)
Posts: 24965
Joined: Sun, 2. Apr 06, 16:38
x4

Post by X2-Illuminatus » Mon, 21. Nov 11, 16:02

Hopefully i can remove/destroy the marine without causing a message to the player,...
The "destroy passenger"-command should work with marines as well.
while typing this up, it makes me wonder if there is a way to set Passenger localvars, so theyd stay with the passenger instead of the ship.
That works without problems.
Nun verfügbar! X3: Farnham's Legacy - Ein neues Kapitel für einen alten Favoriten

Die komplette X-Roman-Reihe jetzt als Kindle E-Books! (Farnhams Legende, Nopileos, X3: Yoshiko, X3: Hüter der Tore, X3: Wächter der Erde)

Neuauflage der fünf X-Romane als Taschenbuch

The official X-novels Farnham's Legend, Nopileos, X3: Yoshiko as Kindle e-books!

Cycrow
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 22238
Joined: Sun, 14. Nov 04, 23:26
x4

Post by Cycrow » Mon, 21. Nov 11, 17:05

marines, pilots and passengers are all the same thing.

infact, setting the marines fighting skill to 0 would turn it back into a passenger. (dont think its possible thou as the command will prevent it)

passengers can be moved between piloting the ship or a general passenger

Firewrath
Posts: 121
Joined: Fri, 3. Aug 07, 05:49
x3tc

Post by Firewrath » Thu, 24. Nov 11, 10:32

Awesome, Thanks for the info. Im going to try to get this going tonight. ^-^
(so glad this thread has stayed on topic, ;))
but as such, :P
is there any like 'behind the scenes' numbers i can alter that would have some effect on ships or how well they fight?
(i was thinking about altering the ship fight skill scripts, but i dont think i want to replace anything used by the vanilla game just yet or unless i Have to,)

i figure i'll set localvars based on the marines skills when converted to a pilot, then run an update script on the ship/pilot every time it makes a kill to make the changes.

A.Persyn
Posts: 121
Joined: Sun, 14. Mar 10, 13:14
x3tc

Marine Pilots

Post by A.Persyn » Sun, 27. Nov 11, 08:06

Greetings,

Here's some insight into adding Marine pilots:

Passengers and Marines are basically the same but Marines are definitely the better choice for adding pilots. Marines are easily acquired while Passengers are not, and Marines have more options and skills to work with.

You move a Marine to the pilot seat using the command:

Code: Select all

= $marine->move passenger to ship $ship: set passenger as pilot=[TRUE]
The pilot, however, is just a copy of the Marine's data; it is not the actual Marine.

When a marine is moved:
  • 1. The Marine is removed from the cargo bay.
    2. The used cargo bay volume is reduced by the volume of the Marine (8 units).
    3. The pilot's data is replaced by the Marine's data (name, trade skill, etc.).
    4. The Marine is hidden onboard the ship, intact.
Once the Marine is moved, it can no longer be viewed on the ship but it is still there.

In order to have access to the Marine, you need to add a local variable to the ship that will hold a pointer to the Marine, regardless of where it is hidden.

Code: Select all

$ship->set local variable: name='The.Actual.Marine' value=$marine
The local variable needs to be added when the Marine is moved. Once the Marine is moved, there is no other way to access it.

The hidden Marine can then be read and updated as normal.

Code: Select all

$marine= $ship->get local variable:  name='The.Actual.Marine'
$name = $marine -> get name
$fighting = $marine get marine fighting skill 
$morale = $marine->get pilot morale
$marine->set marine skill: hacking=20
Even though the pilot's data is a copy of the Marine's data, it is not dynamic and does not update when the Marine's data is changed, and vice verse. The pilot's data still has to be updated manually when changes have been made.

Code: Select all

$marine.fightskill = $marine->get pilot fightskill
$ship->set pilot fightskill to $marine.fightskill
Of course, you can do the reverse, as well.

Code: Select all

$pilot.fightskill = $ship->get pilot fightskill
$marine->set pilot fightskill to $pilot.fightskill
To see a working example of this, add these scripts to your game:

The first script is a Mission Director script that will add a player owned, Argon Express to your current sector with 5 Marines and 5 Passengers onboard. When loaded, it will switch the player's aim to the Express. (Add the script to the 'director' folder.)

Code: Select all

<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet href="director.xsl" type="text/xsl" ?>
<director name="Test Ship" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="director.xsd">
	<documentation>
		<author name="A.Persyn" alias="A.Persyn" contact="a.persyn@thelegions.org" />
		<content name="Test Ship" description="Add a TP with Marines and Passengers onboard" />
		<version number="1.0" date="20111126" status="testing" />
	</documentation>
	<cues>
		<cue name="TestShip">
			<condition>
				<check_all>
					<check_age value="{player.age}" min="1s" />
				</check_all>
			</condition>
			<action>
				<do_all>
					<create_ship name="Test_TP" typename="SS_SH_A_TP" race="player" racelogic="0" >
						<position object="{player.ship}" />
						<sector sector="{player.sector}"/>
						<equipment loadout="maximum" loadoutmask="shields"/>
						<cargo>
							<ware typename="SS_WARE_TECH246" exact="30" comment="Rudder Optimizations"/>
							<ware typename="SS_WARE_TECH213" exact="30" comment="Engine Tunings"/>
							<ware typename="SS_WARE_SW_SPECIAL_1" exact="1" comment="Special Command Software MK1"/>
							<ware typename="SS_WARE_SW_FIGHT_2" exact="1" comment="Fight Command Sofware MK2"/>
							<ware typename="SS_WARE_SOLDIER_2" exact="5"/>
						</cargo>
					</create_ship>
					<do_all exact="5">
						<create_actor race="argon" voiceflags="32" location="passenger" object="Test_TP"/>
					</do_all>
					<set_target object="Test_TP"/>
				</do_all>
			</action>
		</cue>
	</cues>
</director>
The second script is an MSCI script that needs to be run while the playership is targeting the Express. It's a menu that allows you to add a Marine or Passenger as pilot.

Code: Select all

$title = null
$increase = 0

MenuStart:
$ship = get player tracking aim

$menu = create custom menu array

**************************************************************************************************

add custom menu heading to array $menu: title='The Pilot of this ship'
gosub TitleText
add custom menu item to array $menu: text=$title returnvalue=null
$object = $ship->get local variable: name='Hidden.Object'
if $object
  gosub PilotData
else
  $stats.array = 'Choose a pilot for this ship'
end
add custom menu item to array $menu: text=$stats.array returnvalue=null


**************************************************************************************************
add custom menu heading to array $menu: title='The Marines onboard this ship'
gosub TitleText
add custom menu item to array $menu: text=$title returnvalue=null
$marines = $ship->get marines array
if $marines
  $count = size of array $marines
  while $count
    dec $count =
    $object = $marines[$count]
    gosub PilotData
    add custom menu item to array $menu: text=$stats.array returnvalue=$object
  end
else
  $text= 'There are no Marines on this ship'
  add custom menu item to array $menu: text=$text returnvalue=null
end

**************************************************************************************************
add custom menu heading to array $menu: title='The Passengers onboard this ship'
gosub TitleText
add custom menu item to array $menu: text=$title returnvalue=null

$passengers = $ship->get passenger array
if $passengers
  $count = size of array $passengers
  while $count
    dec $count =
    $object = $passengers[$count]
    gosub PilotData
    add custom menu item to array $menu: text=$stats.array returnvalue=$object
  end
else
  $text= 'There are no Passengers on this ship'
  add custom menu item to array $menu: text=$text returnvalue=null
end
**************************************************************************************************
add custom menu heading to array $menu: title='Increase Marine Skills'
$text= 'Increase Marine skills by 1'
add custom menu item to array $menu: text=$text returnvalue=1

$menu.title = 'Choose a Pilot for this Ship:'
$menu.desc = 'Select a Marine or Passenger to be the pilot'
$selected = open custom info menu: title=$menu.title description=$menu.desc option array=$menu maxoptions=99

* If the player presses the escape key or the back arrow (both send the return value of -1), do nothing and exit the menu.
if $selected == -1
  return null
  
  * Verify that the datatype of the selection is either a passenger or marine.
else if is datatyp[ $selected ] == {DATATYP_PASSENGER}
  
  * Set the local variable on the ship that will hold the pointer to the passenger or marine, depending on which was selected.
  $ship->set local variable: name='Hidden.Object' value=$selected
  
  * Move the selection to the pilot's seat
  = $selected->move passenger to ship $ship: set passenger as pilot=[TRUE]
  
  * When a passenger or marine is moved to the pilot's seat, the race of the passenger/marine becomes the owner of the ship.
  * If this were to be an NPC ship that would be fine, but since this is a playership, the ownership needs to be reset
  $ship->set owner race to {Player}
  
else if $selected == 1
  $increase = 1
end

goto label MenuStart

return null

PilotData:
$stats.array = array alloc: size=32
$name = $object -> get name
$race = $object->get owner race
$idc = $object->get ID code

* These are the standard pilot info, they will always have a value from 0 to 30.
$fight = $object->get pilot fightskill
$trade = $object->get pilot tradeskill
$mor = $object->get pilot morale
$agg = $object->get pilot aggression

* This information applies only to marines, fighting will always have a value of at least 1, the others start at zero. The limit for each marine skill is 100 points.
if is marine: passenger/astronaut=$object
  
  $price = $object->get marine buy price
  $salary = $price / 10
  $fskill = $object get marine fighting skill
  $hskill = $object get marine hacking skill
  $eskill = $object get marine engineering skill
  $mskill = $object get marine mechanical skill
  $over = $object get marine overall skill
  
  $fskill = $fskill + $increase
  $object ->set marine skill: fighting=$fskill
  $hskill = $hskill + $increase
  $object ->set marine skill: hacking=$hskill
  $mskill = $mskill + $increase
  $object ->set marine skill: mechanical=$mskill
  $eskill = $eskill + $increase
  $object ->set marine skill: engineering=$eskill
  
  $mtot = $fskill + $hskill + $mskill + $eskill
else
  $mtot = 0
  $fskill = 0
  $hskill = 0
  $mskill = 0
  $eskill = 0
  $over = 0
  $price = 0
  $salary = 0
end
$env = $object->get environment

$total = $fight + $trade + $mor + $agg + $mtot

$price = convert number $price to string
$salary = convert number $salary to string
$fight = convert number $fight to string
$trade = convert number $trade to string
$mor = convert number $mor to string
$agg = convert number $agg to string
$fskill = convert number $fskill to string
$hskill = convert number $hskill to string
$mskill = convert number $mskill to string
$eskill = convert number $eskill to string
$over = convert number $over to string
$total = convert number $total to string


$stats.array[0] = 1
$stats.array[1] = $idc
$stats.array[2] = 70
$stats.array[3] = $name
$stats.array[4] = 260
$stats.array[5] = $race
$stats.array[6] = -510
$stats.array[7] = $price
$stats.array[8] = -460
$stats.array[9] = $salary
$stats.array[10] = -430
$stats.array[11] = $fight
$stats.array[12] = -405
$stats.array[13] = $trade
$stats.array[14] = -380
$stats.array[15] = $mor
$stats.array[16] = -355
$stats.array[17] = $agg
$stats.array[18] = -285
$stats.array[19] = $fskill
$stats.array[20] = -260
$stats.array[21] = $hskill
$stats.array[22] = -235
$stats.array[23] = $mskill
$stats.array[24] = -210
$stats.array[25] = $eskill
$stats.array[26] = -185
$stats.array[27] = $over
$stats.array[28] = -120
$stats.array[29] = $total
$stats.array[30] = -1
$stats.array[31] = $env

endsub

TitleText:
$Pos01 = 1
$text01 = 'ID Code'
$Pos02 = 70
$text02 = 'Name'
$Pos03 = 260
$text03 = 'Race'
$Pos04 = -510
$text04 = 'Price'
$Pos05 = -460
$text05 = 'Salary'
$Pos06 = -430
$text06 = 'F'
$Pos07 = -405
$text07 = 'T'
$Pos08 = -380
$text08 = 'M'
$Pos09 = -355
$text09 = 'A'
$Pos10 = -285
$text10 = 'FS'
$Pos11 = -260
$text11 = 'HS'
$Pos12 = -235
$text12 = 'MS'
$Pos13 = -210
$text13 = 'ES'
$Pos14 = -185
$text14 = 'OS'
$Pos15 = -120
$text15 = 'Total'
$Pos16 = -1
$text16 = 'Location'

$title = array alloc: size=32
$title[0] = $Pos01
$title[1] = $text01
$title[2] = $Pos02
$title[3] = $text02
$title[4] = $Pos03
$title[5] = $text03
$title[6] = $Pos04
$title[7] = $text04
$title[8] = $Pos05
$title[9] = $text05
$title[10] = $Pos06
$title[11] = $text06
$title[12] = $Pos07
$title[13] = $text07
$title[14] = $Pos08
$title[15] = $text08
$title[16] = $Pos09
$title[17] = $text09
$title[18] = $Pos10
$title[19] = $text10
$title[20] = $Pos11
$title[21] = $text11
$title[22] = $Pos12
$title[23] = $text12
$title[24] = $Pos13
$title[25] = $text13
$title[26] = $Pos14
$title[27] = $text14
$title[28] = $Pos15
$title[29] = $text15
$title[30] = $Pos16
$title[31] = $text16

endsub
return null

The advantages of using the hidden Marine approach rather than different local variables should be obvious when you see the menu display.

Since the Marine is going to be used as a pilot, the Marine skills aren't really necessary, but they can be re-purposed to represent other stats like Number of Missions, Ship Kills or anything else that fits the 0 to 100 scale. It does have its limitations but ultimately it is much cleaner than a bunch of local variables.

Have a nice day!

A.Persyn

Firewrath
Posts: 121
Joined: Fri, 3. Aug 07, 05:49
x3tc

Re: Marine Pilots

Post by Firewrath » Mon, 28. Nov 11, 15:31

A.Persyn wrote: <Extensive and Amazing stuff.>
Wow, thats just. Yeah. Wow.
I will totally try that out and look deeper into it when i get time ^-^
but overall i like the idea there, specially the 'hidden marine' stuff, thats rather cool, i had no idea that could be done.

Hrm. this actually points out a problem with the reason i was going to convert them to passengers, is that ships smaller then an M6 cant carry marines, ...but most M5 cant even carry passengers, -_-
I'll have to look into that too now, mebey adding a 'select ship for the marine to pilot' and a list of docked ships...

Anyways. I totally appreciate you taking the time and giving me this information and script. I'll look at it when i can in the next couple of days and let you know how it all works out. ^-^

Post Reply

Return to “X³: Terran Conflict / Albion Prelude - Scripts and Modding”