[HELP] Spawning Capital ship on Gamestart.

The place to discuss scripting and game modifications for X4: Foundations.

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

blongo
Posts: 12
Joined: Sat, 15. Dec 18, 16:44

[HELP] Spawning Capital ship on Gamestart.

Post by blongo »

I'm just messing around. I was able to turn the main character of the traveler start into a lizard. Replaces his ship with a kestral. Now I'm wondering if you guys know any snippets of code that i could borrow to spawn one of those xl ships right next to the player?

I am confused on how its done.
Spoiler
Show

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<diff xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
	<add sel="/gamestarts">
    <gamestart id="blngo_LuckyLizard" name="Lizard" description="You are a lizard harry, Deal with it." image="gamestart_2" group="1">
      <location galaxy="xu_ep2_universe_macro" zone="zone001_cluster_47_sector001_macro">
        <position x="-24299.879" y="-249.256" z="-13310.063"/>
        <rotation yaw="-61.50683" pitch="14.70719" roll="43.06808"/>
      </location>
      <player macro="character_player_trade_macro" money="200000" name="{1021,202}"> <!--peter-->
        <ship macro="ship_tel_s_scout_01_a_macro">
        </ship>
        <inventory>
					<ware ware="inv_timewarp" amount="1" />
					<ware ware="inv_interfaceunit" amount="6" />
          <ware ware="weapon_gen_spacesuit_repairlaser_01_mk1" amount="1" />
          <ware ware="software_scannerobjectmk3" amount="1" />
        </inventory>
        <blueprints>
          <ware ware="clothingmod_0001" />
          <ware ware="clothingmod_0002" />
          <ware ware="paintmod_0006"/>
          <ware ware="paintmod_0048"/>
          <ware ware="paintmod_0049"/>
          <ware ware="paintmod_0050"/>
        </blueprints>
        <research>
          <ware ware="research_radioreceiver" />
          <ware ware="research_sensorbooster" />
          <ware ware="research_tradeinterface" />
        </research>
        <theme paint="painttheme_player_01" />
      </player>
    </gamestart>
  </add>
</diff>
Tyrant597
Posts: 299
Joined: Wed, 9. Apr 08, 05:52
x4

Re: [HELP] Spawning Capital ship on Gamestart.

Post by Tyrant597 »

First find a safe position near the player.
Spoiler
Show

Code: Select all

<get_safe_pos result="$Position" sector="$Location" object="$positionObject" allowyaxis="false" radius="5km" max="10km"/>
Then create the ship with the position found above.
Spoiler
Show

Code: Select all

<create_ship name="$ship" macro="macro.ship_whatever_xl_ship_macro" sector="$sector">
            <owner exact="faction.ownerless"/>
            <position ="$Position"/>
            <rotation yaw="-12deg" pitch="9deg" roll="10deg"/>
          </create_ship>

Just change the macro to whatever you want to spawn, faction to faction.player i assume you would want? =P
Ship macros are in \assets\units\.
You don't talks about X:Rebirth...
X4 Mods: Collect Inventory Wares Stations Supply Build Storage Mass Move Marines
blongo
Posts: 12
Joined: Sat, 15. Dec 18, 16:44

Re: [HELP] Spawning Capital ship on Gamestart.

Post by blongo »

Tyrant597 wrote: Thu, 27. Dec 18, 23:34 First find a safe position near the player.
Spoiler
Show

Code: Select all

<get_safe_pos result="$Position" sector="$Location" object="$positionObject" allowyaxis="false" radius="5km" max="10km"/>
Then create the ship with the position found above.
Spoiler
Show

Code: Select all

<create_ship name="$ship" macro="macro.ship_whatever_xl_ship_macro" sector="$sector">
            <owner exact="faction.ownerless"/>
            <position ="$Position"/>
            <rotation yaw="-12deg" pitch="9deg" roll="10deg"/>
          </create_ship>

Just change the macro to whatever you want to spawn, faction to faction.player i assume you would want? =P
Ship macros are in \assets\units\.
I don't know how to call scripts once the game starts, how would i add that to the game start?
Tyrant597
Posts: 299
Joined: Wed, 9. Apr 08, 05:52
x4

Re: [HELP] Spawning Capital ship on Gamestart.

Post by Tyrant597 »

blongo wrote: Fri, 28. Dec 18, 00:23 I don't know how to call scripts once the game starts, how would i add that to the game start?
Spoiler
Show

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="your_script_name_here" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
  <cues>

    <cue name="whatever_you_want>
      <conditions>
        <event_cue_signalled cue="md.Setup.GameStart" /> <!--This cue will get "triggered" every time a new game gets setup, so it will load this md script when md.Setup.GameStart gets called -->
      </conditions>
      <actions>
      	<do_stuffs_here />
      	<create_ship etc />
      </actions>
    </cue>
 </cues>
</mdscript>
      
      
Create your own your_script_name_here.xml file in your extensions/mod_name/md folder, paste that in there. Anything you add after <actions> will be done as soon as a new game is setup. (Not every time a savegame is loaded, though.)
You don't talks about X:Rebirth...
X4 Mods: Collect Inventory Wares Stations Supply Build Storage Mass Move Marines
blongo
Posts: 12
Joined: Sat, 15. Dec 18, 16:44

Re: [HELP] Spawning Capital ship on Gamestart.

Post by blongo »

I did manage to get it to work, but i basically just peaked/copied what this guy did. viewtopic.php?t=404771
So hurray for SilverXarrow.

@Tyrant598 thank you for your help, you did lead me in the right direction.

Continuing from here....

Is there anyway i could get the player to start in a ship, docked in a capital ship?

unless anyone really wants to keep the thread alive, I'm fine with it dieing right here.

Return to “X4: Foundations - Scripts and Modding”