Modding Fleets for X Rebirth

The place to discuss scripting and game modifications for X Rebirth.

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

dwharper34
Posts: 22
Joined: Fri, 30. Dec 16, 01:08

Modding Fleets for X Rebirth

Post by dwharper34 » Fri, 30. Dec 16, 02:23

I created an Arawn Fleet Mod that seems to work well. For 1 Arawn group, I have about 40 ships of 7 types.

When I create the ships, I am able to assign them to the flagship Arawn. When I play the game the ships are assigned to the Arawn but have no orders. I have to select each ship in the group and assign them to the Arawn and then they will have the command to follow Arawn. I want to send a Arawn group to each of my 20+ stations so this is extremely time consuming. I'd rather just play the game.

I have tried to issue commands to "Escort Arawn" during creation but have had no luck.

In the old XMDGuide v122.pdf which is from 2007 they have a line
<command command="follow" commandobject="{player.ship}"/>
which looked like exactly what I needed. This does not work in Rebirth. I get a "command", "command="follow" and "command.follow" not recognized.

I have tried the following:
<create_ship name="$Katana" macro="units_size_m_katana_macro" zone="player.zone" >
<owner exact="faction.player" overridenpc="true" />
<pilot actor="null" />
<units>
<unit category="unitcategory.defence" mk="4" exact="20" />
</units>
<position x="-1km" y="1km" z="-$j" object="global.$Arawn" />
<rotation yaw="0deg" pitch="0deg" roll="0deg" />
<set_command object="$Katana" command="command.follow" commander="global.$Arawn" />
<command.follow object="$Katana" commander="global.$Arawn" />

</create_ship>

<create_cue_actor name="$Pilot_Katana" type="entitytype.pilot" cue="CreateArawnGroups" >
<owner exact="faction.player" />
<skills>
<skill type="boarding" exact="5" />
<skill type="combat" exact="5" />
<skill type="engineering" exact="5" />
<skill type="leadership" exact="5" />
<skill type="management" exact="5" />
<skill type="morale" exact="5" />
<skill type="navigation" exact="5" />
<skill type="science" exact="5" />
</skills>
</create_cue_actor>
<assign_pilot actor="$Pilot_Katana" object="$Katana" />
<set_object_commander object="$Katana" commander="global.$Arawn" />
<start_script object="$Ship" commander="$ShipFlag" name="'command.commander.follow'" >
<param name="object" value="$Katana" />
<param name="commander" value="global.$Arawn" />
</start_script>

<start_script object="$Pilot_Katana" name="'player.default'" />
<remove_value name="$Katana" />
<remove_value name="$Pilot_Katana" />

command.commander.follow.xml
<?xml version="1.0" encoding="iso-8859-1" ?>
<aiscript name="command.commander.follow" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="aiscripts.xsd" priority="10">
<params>
</params>
<init>
<set_command object="{$Ship}" command="command.follow" commander="{$ShipFlag}"/>
</init>
<attention min="unknown">
<actions>
<command.follow object="{$Ship}" commander="{$ShipFlag}"/>
</actions>
</attention>
</aiscript>



I don't have any idea how to issue orders during the ship creation and have not been able to google information to do it. I would appreciate your help. Thanks in advance!

I never played the other X games, but I love Rebirth. Thanks Egosoft!

iforgotmysocks
Posts: 1244
Joined: Fri, 8. Nov 13, 22:35
x4

Post by iforgotmysocks » Fri, 30. Dec 16, 05:19

Hey dwharper. :)

Ur script was a little confusing so i wrote a small script that spawns u a small fleet with subsquads and fightersupport that have standing orders to support their commanders.

I documented the most important parts, if you still have questions, just ask.
PS: Last task for you is to figure out how to do this 20 times and how to adjust it to your own squad-type. :p

As File

Code: Select all

<mdscript name="SpawnShips" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
  <cues>
    <cue name="Spawn_Ships" instantiate="false" namespace="this">
      <conditions>
        <check_any>
          <event_cue_signalled cue="md.Setup.GameStart"/>
          <event_game_loaded />
        </check_any>
      </conditions>
      <delay min="0.5s" />
      <actions>

        <!-- First we create the arawn, empty for now, we'll add the crew later. -->
        <create_ship name="$ship" macro="macro.units_size_xl_capital_destroyer_1_macro" zone="player.primaryship.zone">
          <owner exact="faction.player" overridenpc="true"/>
          <pilot actor="null"/>
          <defence actor="null"/>
          <engineer actor="null"/>
          <units>
            <unit category="unitcategory.transport" mk="1" exact="50" />
            <unit category="unitcategory.welder" mk="1" exact="250" />
            <unit category="unitcategory.defence" mk="2" exact="0"/>
          </units>
          <cargo>
            <wares list="[ware.fuelcells]">
              <fillpercent exact="100"/>
            </wares>
          </cargo>
          <safepos x="1500m" y="-100m"/>
        </create_ship>

        <!-- Now we find the dock, create the crew and the npcs to the dock.-->
        <find_dock_location name="$target_dock" container="$ship" size="tag.dock_p" />
        <create_platform_actor name="$defenceOfficer" type="entitytype.defencecontrol" dockingbay="$target_dock.component" ref="fighter_omicron_lyrae_random">
          <owner exact="faction.player"/>
          <skills>
            <skill type="boarding" min="1" max="3" />
            <skill type="combat" min="5" max="5" />
            <skill type="engineering" min="1" max="5" />
            <skill type="leadership" min="5" max="5" />
            <skill type="management" min="1" max="4" />
            <skill type="morale" min="5" max="5" />
            <skill type="navigation" min="1" max="5" />
            <skill type="science" min="1" max="3" />
          </skills>
        </create_platform_actor>

        <create_platform_actor name="$commander" type="entitytype.commander" dockingbay="$target_dock.component" ref="trader_omicron_lyrae_random">
          <owner exact="faction.player"/>
          <skills>
            <skill type="boarding" min="1" max="3" />
            <skill type="combat" min="5" max="5" />
            <skill type="engineering" min="1" max="5" />
            <skill type="leadership" min="5" max="5" />
            <skill type="management" min="1" max="4" />
            <skill type="morale" min="5" max="5" />
            <skill type="navigation" min="5" max="5" />
            <skill type="science" min="1" max="3" />
          </skills>
        </create_platform_actor>

        <create_platform_actor name="$engineer" type="entitytype.engineer" dockingbay="$target_dock.component" ref="engineer_omicron_lyrae_random">
          <owner exact="faction.player"/>
          <skills>
            <skill type="boarding" min="1" max="3" />
            <skill type="combat" min="1" max="3" />
            <skill type="engineering" min="5" max="5" />
            <skill type="leadership" min="1" max="3" />
            <skill type="management" min="1" max="4" />
            <skill type="morale" min="1" max="5" />
            <skill type="navigation" min="1" max="5" />
            <skill type="science" min="1" max="3" />
          </skills>
        </create_platform_actor>

        <!-- Now we assign the crew to the arawn,-->
        <assign_pilot actor="$commander" object="$ship"/>
        <assign_defence_manager actor="$defenceOfficer" object="$ship"/>
        <assign_engineer actor="$engineer" object="$ship"/>
        <!-- add the arawn to our squad, -->
        <set_object_commander object="$ship" commander="player.primaryship"/>
        <!-- and give the crew the according ai scripts they need to fullfill their tasks.-->
        <start_script object="$commander" name="'player.default'"/>
        <start_script object="$defenceOfficer" name="'fight.defend.capital'"/>
        <start_script object="$engineer" name="'engineer.ai'"/>
        <!-- We also can enable auto refuling. (Setting this manually for a large number of caps is painfull)-->
        <set_value name="$commander.$config_autorefuel" exact="1" />


        <!-- Since we want to add more ships to the arawn now, we need a list. -->
        <create_list name="$ships2"/>
        <!-- Now we specify how often we want to create the following ship, in this case a Taranis and we want 3 -->
        <do_all exact="3" counter="$i">
          <!-- Again, first we create the ships and add them to the shiplist. -->
          <create_ship name="$ship2" macro="macro.units_size_xl_capital_destroyer_2_macro" zone="$ship.zone">
            <owner exact="faction.player" overridenpc="true"/>
            <pilot actor="null"/>
            <defence actor="null"/>
            <engineer actor="null"/>
            <units>
              <unit category="unitcategory.transport" mk="1" exact="5" />
              <unit category="unitcategory.welder" mk="1" exact="45" />
              <unit category="unitcategory.defence" mk="2" exact="0"/>
            </units>
            <cargo>
              <wares list="[ware.fuelcells]">
                <fillpercent exact="100"/>
              </wares>
            </cargo>
            <safepos x="1500m" y="-100m"/>
          </create_ship>
          <append_to_list name="$ships2" exact="$ship2"/>
        </do_all>

        <!-- and then we go through all the ships assign npcs, crew and aiscripts -->
        <do_all exact="$ships2.count" counter="$i">

          <find_dock_location name="$target_dock" container="$ships2.{$i}" size="tag.dock_p" />
          <create_platform_actor name="$defenceOfficer" type="entitytype.defencecontrol" dockingbay="$target_dock.component" ref="fighter_omicron_lyrae_random">
            <owner exact="faction.player"/>
            <skills>
              <skill type="boarding" min="1" max="3" />
              <skill type="combat" min="5" max="5" />
              <skill type="engineering" min="1" max="5" />
              <skill type="leadership" min="5" max="5" />
              <skill type="management" min="1" max="4" />
              <skill type="morale" min="5" max="5" />
              <skill type="navigation" min="1" max="5" />
              <skill type="science" min="1" max="3" />
            </skills>
          </create_platform_actor>

          <create_platform_actor name="$commander" type="entitytype.commander" dockingbay="$target_dock.component" ref="trader_omicron_lyrae_random">
            <owner exact="faction.player"/>
            <skills>
              <skill type="boarding" min="1" max="3" />
              <skill type="combat" min="5" max="5" />
              <skill type="engineering" min="1" max="5" />
              <skill type="leadership" min="5" max="5" />
              <skill type="management" min="1" max="4" />
              <skill type="morale" min="5" max="5" />
              <skill type="navigation" min="5" max="5" />
              <skill type="science" min="1" max="3" />
            </skills>
          </create_platform_actor>

          <create_platform_actor name="$engineer" type="entitytype.engineer" dockingbay="$target_dock.component" ref="engineer_omicron_lyrae_random">
            <owner exact="faction.player"/>
            <skills>
              <skill type="boarding" min="1" max="3" />
              <skill type="combat" min="1" max="3" />
              <skill type="engineering" min="5" max="5" />
              <skill type="leadership" min="1" max="3" />
              <skill type="management" min="1" max="4" />
              <skill type="morale" min="1" max="5" />
              <skill type="navigation" min="1" max="5" />
              <skill type="science" min="1" max="3" />
            </skills>
          </create_platform_actor>

          <assign_pilot actor="$commander" object="$ships2.{$i}"/>
          <assign_defence_manager actor="$defenceOfficer" object="$ships2.{$i}"/>
          <assign_engineer actor="$engineer" object="$ships2.{$i}"/>
          <!-- Here we want to make sure that our Taranis are in the arwans squad -->
          <set_object_commander object="$ships2.{$i}" commander="$ship"/>
          <!-- and escort it.-->
          <start_script object="$commander" name="'move.escort'">
            <param name="target" value="$ship"/>
          </start_script>
          <start_script object="$defenceOfficer" name="'fight.defend.capital'"/>
          <start_script object="$engineer" name="'engineer.ai'"/>
          <set_value name="$commander.$config_autorefuel" exact="1" />

          <!-- Before we close our loop we want to add some fighters to each Taranis. -->
          <do_all exact="24" counter="$j">
            <create_ship macro="units_size_s_ship_ar_military_06_macro" name="$smallship" zone="$ships2.{$i}.zone">
              <owner exact="faction.player" overridenpc="1"/>
              <pilot ref="trader_albion_random"/>
              <drop ref="ship_medium_civilian"/>
              <safepos object="$ships2.{$i}" max="1km" radius="500m"/>
            </create_ship>
            <!-- Now we assign each fighter to the according Taranis-->
            <set_object_commander object="$smallship" commander="$ships2.{$i}"/>
            <!-- and give them the command to escort it.-->
            <start_script object="$smallship.pilot" name="'move.escort'">
              <param name="target" value="$ships2.{$i}"/>
            </start_script>
          </do_all>
        </do_all>

        <!-- And now all that's left for you to figure out is how to do this 20 times and adjust the script to your own squadron type. :p -->



      </actions>
    </cue>
  </cues>
</mdscript>

Sparky Sparkycorp
Moderator (English)
Moderator (English)
Posts: 8074
Joined: Tue, 30. Mar 04, 12:28
x4

Post by Sparky Sparkycorp » Fri, 30. Dec 16, 11:10

Welcome to the world of modding :)

In case some of it is new and potentially useful, please see the following information for supporting modding on the Rebirth wiki. Some of the info is provided by Egosoft and some of the info is provided by modders.

https://www.egosoft.com:8444/confluence ... ng+support

dwharper34
Posts: 22
Joined: Fri, 30. Dec 16, 01:08

Post by dwharper34 » Sat, 31. Dec 16, 05:09

I'm having problems. Was the file "spawnships" you wrote supposed to run. I wanted to see if you wou0ld get the same errors I was getting but I ran it several times now and it produces nothing and there are no errors in the debug.log.

I was unable to get my mod to start with " <event_game_loaded />" or "<event_cue_signalled cue="md.Setup.GameStart"/> last night so I started going back to earlier versions until I was able to get it to run. Now I added the lines

Code: Select all

<assign_pilot actor="$commander" object="$shipTaranis" />
<assign_defence_manager actor="$defenceNPC" object="$shipTaranis" />
<assign_engineer actor="$engineer" object="$shipTaranis" />
<!-- Here we want to make sure that our Taranis' are in the Arwans squad -->
<set_object_commander object="$shipTaranis" commander="global.$shipArawn" />
<!-- and escort it.-->
<start_script object="$commander" name="'move.escort'">
  <param name="target" value="global.$shipArawn"/>
</start_script>
<start_script object="$commander" name="'player.default'" />
<start_script object="$defenceNPC" name="'fight.defend.capital'" />
<start_script object="$engineer" name="'engineer.ai'" />
and ran into a lot of errors.
  • [General] 2.01 ======================================
    [=ERROR=] 2.01 When calling script move.escort on entity 0x214ed - script parameter "target" was not provided!
    [General] 2.01 ======================================
    [General] 2.01 ======================================
    [=ERROR=] 2.01 When calling script move.escort on entity 0x214ed - script parameter "$$commander" was not expected!
    [General] 2.01 ======================================
    [General] 2.01 ======================================
    [=ERROR=] 2.01 Error in AI script move.escort on entity 0x214ed: Property lookup failed: $target
    * Expression: $target == 'commander'
    [General] 2.01 ======================================
    [General] 2.01 ======================================
    [=ERROR=] 2.01 Error in AI script move.escort on entity 0x214ed: Property lookup failed: $target
    * Expression: $target
    [General] 2.01 ======================================
I was able to add the fighter section, without changing it much, to my Balors group. It builds the fighters but they have no orders.

I just made a few changes and now the fighters have orders to Patrol. That's a welcome change. Let me play around with the other ships and see if I can get them to work.[/list][/code]
Last edited by dwharper34 on Wed, 4. Jan 17, 05:10, edited 3 times in total.

iforgotmysocks
Posts: 1244
Joined: Fri, 8. Nov 13, 22:35
x4

Post by iforgotmysocks » Sat, 31. Dec 16, 05:37

How didn't it run for you?
All you need to do is download the file, extract it and drop the folder in your extensions folder. Then u can play around with the script and see what works and what doesn't. ^^

In order to tell you what's wrong with ur current script u'd have to post or upload it. All i can tell u from those errors is that u're assigning wrong variables and u seem to have some typos. :p

dwharper34
Posts: 22
Joined: Fri, 30. Dec 16, 01:08

Post by dwharper34 » Sat, 31. Dec 16, 13:00

I sure appreciate your help. I've tried to learn as much as I can, but I am just learning how to do this. I just started a couple of weeks ago.

I did drop the file in the extension folder and it did not run. I've restarted the game at least 10 times with it in there and nothing. I am running the GOG version if that makes any difference. I know that a lot of code that works for other people won't work for me. I just keep trying different ways until it does.

I've added your fighter groups to 5 destroyers groups with 5 ships in each group and they are all working correctly so far. That gives me hope! I still cannot run my mod on a game load. Another mystery.

I liked the code you sent me and sometime in the future I will try to use that format. But I was so close to making this mod work, I didn't want to change the flow.

I would also like to know how I can use a unused keyboard key to map several options so that I could press a key to run a selected script file.

If you would like to look at my mod, that would be great. Is there some place I could upload it to. It is pretty long.

Thanks again!
Last edited by dwharper34 on Sun, 1. Jan 17, 01:46, edited 3 times in total.

Sao t'Lp
Posts: 135
Joined: Tue, 17. Nov 09, 21:18
x4

Post by Sao t'Lp » Sat, 31. Dec 16, 14:19

AFAIK you cannot simply drop a file inside the extension folder, you need to create a folder (referred to as "mod directory") inside the extensions folder which consists of your files and a content.xml file. Following text is extracted from Observse's Modding Guide:
Example 1: Create a mod extension

Before we do anything else, we first need to establish a folder location for our mod files.

1. There is a game folder named extensions located off the game root directory. You may need to create this directory if it doesn't already exist.
[...]
4. The most basic mod extension consists of a single mod directory and content.xml. Such a mod wouldn't actually do anything, but it would show in the menu and could be activated and deactivated there.
The contents of the content.xml should be:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<!-- save=false prevents the mod from inserting itself into savegames -->
<content id="your_id" name="YourName" description="YourDescription" author="You" version="1.0" save="false" date="December 31, 2016">
  <!-- If you want to support further languages just insert another text element and change the language attribute -->
  <text language="44" name="YourModsNameInEnglish" description="YourModsDescriptionInEnglish" author="YOU" />
</content>
Then you need to create a folder inside your extensions folder which has the same name like the folder in which your script would go without using extensions. Some important file locations which give a hint on how to name the folder (again extracted from Oberserve's Modding Guide):
There are many Rebirth files that will be of interest to modders. Here are some important file locations:

\aiscripts - Contains script for controlling various aspects of AI (fight, move, mine, etc).
\extensions - This is where your distributed mods go
\index - components.xml and macros.xml. There are two important files that reference other files and locations.
\libraries - Files defining a variety of game elements.
\maps - Map files for Galaxy, clusters, Highways and zones
\md - Mission files using Mission Director
\t - Language files
So if your file is a md script you should put it inside a folder called md inside your mod directory. The structure of your mod would then look like this:

Code: Select all

extensions
|
|---your_mod_directory
...  |
     |---content.xml
     |---md
          |
          |--- your_mod_file.xml
After you have done all this, the game should be able to find your mod and load it. Hope this helps!

EDIT: Observe's Modding guide can be found here: http://forum.egosoft.com/viewtopic.php?t=347831

EDIT2: Or you do it as iforgotmysocks said and put the whole(!) folder inside the extensions directory
You want Split? :split:

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sat, 31. Dec 16, 14:27

content.xml is nice to have for published mods, but technically not needed ;) to create a new extension just create a folder in your extensions folder - Extension ID and name will be taken from the folder name in this case ;) (very useful for quick experiments)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

Sao t'Lp
Posts: 135
Joined: Tue, 17. Nov 09, 21:18
x4

Post by Sao t'Lp » Sat, 31. Dec 16, 14:32

That's good to know, thank you for the hint!
You want Split? :split:

dwharper34
Posts: 22
Joined: Fri, 30. Dec 16, 01:08

Post by dwharper34 » Sun, 1. Jan 17, 01:31

Thanks for the Information!

I see why the spawnships didn't run. It was because I created a new folder called spawnships and put the spawnships.zip inside and extracted it. It was called spawnships as well. Then, later without remembering what I did, I copied the outer folder to extensions with the zip file and spawnships folder inside it. I'm sorry, my mistake! :oops:

I am having problems with $smallship.pilot. It works fine in the fighter code:

Code: Select all

<do_all exact="$iFighters" counter="$k">
<create_ship macro="units_size_s_faltor_sentinel_macro" name="$smallship" zone="$ship.zone">
<owner exact="faction.player" overridenpc="1"/>
<pilot ref="trader_albion_random"/>
<drop ref="ship_medium_civilian"/>
<safepos object="$ship" max="1km" radius="500m"/>
</create_ship>
<create_cue_actor name="$smallship.pilot" type="entitytype.pilot" cue="CreateArawnFleets" >
<owner exact="faction.player" />
<skills>
<skill type="boarding" exact="5" />
<skill type="combat" exact="5" />
<skill type="engineering" exact="5" />
<skill type="leadership" exact="5" />
<skill type="management" exact="5" />
<skill type="morale" exact="5" />
<skill type="navigation" exact="5" />
<skill type="science" exact="5" />
</skills>
</create_cue_actor>
[color=#AACC00]<assign_pilot actor="$smallship.pilot" object="$smallship" />
<!-- Now we assign each fighter to this Balor -->
<set_object_commander object="$smallship" commander="$ship"/>
<!-- and give them the command to escort it.-->
<start_script object="$smallship.pilot" name="'move.escort'">
<param name="$smallship" value="$ship"/>
</start_script>
<remove_value name="$smallship.pilot" />
<remove_value name="$smallship" />
</do_all>
This creates the fighters, assigns them and gives them orders to Patrol.

Now this is the code for my Katanas:

Code: Select all

<do_all exact="$iKatanas" counter="$j">
<create_ship name="$smallship" macro="units_size_m_katana_macro" zone="global.$shipArawn.zone" >
<owner exact="faction.player" overridenpc="true" />
<pilot actor="null" />
<pilot ref="trader_albion_random"/>
<units>
<unit category="unitcategory.defence" mk="4" exact="20" />
</units>
<position x="-1km" y="1km" z="-$j" object="global.$shipArawn" />
<rotation yaw="0deg" pitch="0deg" roll="0deg" />
</create_ship>
<create_cue_actor name="$smallship.pilot" type="entitytype.pilot" cue="CreateArawnFleets" >
<owner exact="faction.player" />
<skills>
<skill type="boarding" exact="5" />
<skill type="combat" exact="5" />
<skill type="engineering" exact="5" />
<skill type="leadership" exact="5" />
<skill type="management" exact="5" />
<skill type="morale" exact="5" />
<skill type="navigation" exact="5" />
<skill type="science" exact="5" />
</skills>
</create_cue_actor>
<assign_pilot actor="$smallship.pilot" object="$smallship" />
<!-- Here we want to make sure that our Katanas are in the Arwans squad -->
<set_object_commander object="$smallship" commander="global.$shipArawn"/>
<!-- and escort it.-->
<start_script object="$smallship.pilot" name="'move.escort'">
<param name="$smallship" value="global.$shipArawn"/>
</start_script>
<start_script object="$smallship.pilot" name="'player.default'" />
<remove_value name="$smallship.pilot" />
<remove_value name="$smallship" />
</do_all>
This creates the Katanas, but does not give them a pilot or orders.

I also get errors:
  • [General] 2.00 ======================================
    [=ERROR=] 2.00 Error in MD cue md.CreateArawnFleets.CreateArawnFleets: Failed to set component.{0x24bdbL}.pilot to value component.{0x24c5aL}
    * Expression: $smallship.pilot
    [General] 2.00 ======================================
    [General] 2.00 ======================================
    [=ERROR=] 2.00 Error in MD cue md.CreateArawnFleets.CreateArawnFleets: Evaluated value 'null' is not of type component
    * Expression: $smallship.pilot
    [General] 2.00 ======================================
    [General] 2.00 ======================================
    [=ERROR=] 2.00 Error in MD cue md.CreateArawnFleets.CreateArawnFleets: Evaluated value 'null' is not of type component
    * Expression: $smallship.pilot
    [General] 2.00 ======================================
    [General] 2.00 ======================================
    [=ERROR=] 2.00 Error in MD cue md.CreateArawnFleets.CreateArawnFleets: Evaluated value 'null' is not of type component
    * Expression: $smallship.pilot
    [General] 2.00 ======================================
    [General] 2.00 ======================================
    [=ERROR=] 2.00 Error in MD cue md.CreateArawnFleets.CreateArawnFleets: Failed to remove component.{0x24bdbL}.pilot
    * Expression: $smallship.pilot
    [General] 2.00 ======================================
Why do all of the nested do_alls for the fighters work and not any of the destroyers, Katana or Drostan do_alls, which are nested in the main do_all, work? The Katanas and Drostans basically use the same code.

This line:

Code: Select all

<param name="$smallship" value="global.$shipArawn"/>
gives me the error:
  • [General] 2.00 ======================================
    [=ERROR=] 2.00 When calling script move.escort on entity 0x254b6 - script parameter "$$smallship" was not expected!
    [General] 2.00 ======================================
The script "move.escort" creates the error. Removing the dollar sign before smallship corrects the problem and removes a ton of errors.

On all of my Destroyers I have the same problem with ship commanders. If I use $ship.commander I get the following errors:
  • [General] 2.00 ======================================
    [=ERROR=] 2.00 Error in MD cue md.CreateArawnFleets.CreateArawnFleets: Failed to set component.{0x25289L}.commander to value component.{0x25402L}
    * Expression: $ship.commander
    [General] 2.00 ======================================
    [General] 2.00 ======================================
    [=ERROR=] 2.00 Error in MD cue md.CreateArawnFleets.CreateArawnFleets: Evaluated value 'null' is not of type component
    * Expression: $ship.commander
    [General] 2.00 ======================================
    [General] 2.00 ======================================
    [=ERROR=] 2.00 Error in MD cue md.CreateArawnFleets.CreateArawnFleets: Evaluated component 0x2462e 'Arawn' is not of class entity
    * Expression: $ship.commander
    [General] 2.00 ======================================
    [General] 2.00 ======================================
    [=ERROR=] 2.00 Error in MD cue md.CreateArawnFleets.CreateArawnFleets: Evaluated component 0x2462e 'Arawn' is not of class entity
    * Expression: $ship.commander
    [General] 2.00 ======================================
This creates the Destroyers, but does not give them a commander or orders.

I can rename $ship.commander to $commander. It will create a commander but He does not receive orders.

I'm not sure what "'Arawn' is not of class entity" means.

I appreciate all the help everyone has given me! Thanks!
Last edited by dwharper34 on Sun, 1. Jan 17, 05:07, edited 2 times in total.

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 1. Jan 17, 02:52

Just for the Issues i can immediately see on the Posted Code, too tired for more than a quick look though:
the fisrt which you says it works, but it
=> Creates unneeded NPCs (i think)
=> and doesnt assign/use the pilot var properly
changes:

<do_all exact="$iFighters" counter="$k">
<create_ship macro="units_size_s_faltor_sentinel_macro" name="$smallship" zone="$ship.zone">
<owner exact="faction.player" overridenpc="1"/>
<pilot actor="null"/>
<drop ref="ship_medium_civilian"/>
<safepos object="$ship" max="1km" radius="500m"/>
</create_ship>
<create_cue_actor name="$smallship_pilot" type="entitytype.pilot" cue="CreateArawnFleets">
<owner exact="faction.player"/>
<skills>
<skill type="boarding" exact="5"/>
<skill type="combat" exact="5"/>
<skill type="engineering" exact="5"/>
<skill type="leadership" exact="5"/>
<skill type="management" exact="5"/>
<skill type="morale" exact="5"/>
<skill type="navigation" exact="5"/>
<skill type="science" exact="5"/>
</skills>
</create_cue_actor>
<assign_pilot actor="$smallship_pilot" object="$smallship"/>
<!-- Now we assign each fighter to this Balor -->
<set_object_commander object="$smallship" commander="$ship"/>
<!-- and give them the command to escort it.-->
<start_script object="$smallship.pilot" name="'move.escort'">
<param name="$smallship" value="$ship"/>
</start_script>
<remove_value name="$smallshi]p_p[/colorilot"/>
<remove_value name="$smallship"/>
</do_all>

First we dont want to create an Actor with the Ship, therefore set it to null
Second the EXPRESSION $smallship.pilot refers to the pilot of $smallship - which is not existent at this point (you did create it with the Ship, but i just nulled that since usually its created seperately because that has better options). It also is a Readonly-Vaue. to make it a proper Var use _ instead of . ( . is a seperatior for property chains)
this change is also necesary for when the Pilot is assigned, since he is not assigned yet. After this we can access him via the property .pilot of $smallship, therefore $smallship.pilot can stay as is after that. (except for the cleanup at the end where used Vars are removed)



now the second Code:
=> you have two Pilots Created with the Ship, which is not Valid (i deleted one)
=> Again the same Mistake with $smallship.pilot as before
=> also launching 2 Scripts immediately after another is pointless, i removed that


<do_all exact="$iKatanas" counter="$j">
<create_ship name="$smallship" macro="units_size_m_katana_macro" zone="global.$shipArawn.zone">
<owner exact="faction.player" overridenpc="true"/>
<pilot actor="null"/>
<units>
<unit category="unitcategory.defence" mk="4" exact="20"/>
</units>
<position x="-1km" y="1km" z="-$j" object="global.$shipArawn"/>
<rotation yaw="0deg" pitch="0deg" roll="0deg"/>
</create_ship>
<create_cue_actor name="$smallship_pilot" type="entitytype.pilot" cue="CreateArawnFleets">
<owner exact="faction.player"/>
<skills>
<skill type="boarding" exact="5"/>
<skill type="combat" exact="5"/>
<skill type="engineering" exact="5"/>
<skill type="leadership" exact="5"/>
<skill type="management" exact="5"/>
<skill type="morale" exact="5"/>
<skill type="navigation" exact="5"/>
<skill type="science" exact="5"/>
</skills>
</create_cue_actor>
<assign_pilot actor="$smallship_pilot" object="$smallship"/>
<!-- Here we want to make sure that our Katanas are in the Arwans squad -->
<set_object_commander object="$smallship" commander="global.$shipArawn"/>
<!-- and escort it.-->
<start_script object="$smallship.pilot" name="'player.default'"/>
<remove_value name="$smallship_pilot"/>
<remove_value name="$smallship"/>
</do_all>


thats it for the Issues i could see in the Snippets posted, but usually the whole context is more useful to Debug stuff..
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

dwharper34
Posts: 22
Joined: Fri, 30. Dec 16, 01:08

Post by dwharper34 » Sun, 1. Jan 17, 04:00

Thank you very much. I've learned so much from you and iforgotmysocks, I think you've helped me solve most of my problems.

I have a question about launching 2 scripts together. For my destroyers I have the following lines:

Code: Select all

<start_script object="$ship.commander" name="'move.escort'">
<param name="$ship" value="global.$shipArawn"/>
</start_script>
<start_script object="$ship_commander" name="'player.default'" />
Should I delete the second one here as well?

Thanks again! You guys are great!

iforgotmysocks
Posts: 1244
Joined: Fri, 8. Nov 13, 22:35
x4

Post by iforgotmysocks » Sun, 1. Jan 17, 05:15

dwharper34 wrote: launching 2 scripts together
That doesn't work. Entities can only have one ai script running at a time. In this case the first script gets cancled and the second one is executed. So ya, go ahead and remove the second one. :)

dwharper34
Posts: 22
Joined: Fri, 30. Dec 16, 01:08

Post by dwharper34 » Sun, 1. Jan 17, 12:39

Thanks for your help!

My mod is working great except it will not start on event_game_loaded. I don't know what could be causing it.

My CreateArawnFleets.xml starts with:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="CreateArawnFleets" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
  <cues>
     <cue name="CreateArawnFleets" instantiate="false" namespace="this">
         <conditions>
            <check_any>
                 <event_cue_signalled cue="md.Setup.GameStart"/>
                 <event_game_loaded />
           </check_any>
        </conditions>
        <delay exact="1s"/>	
        <!-- Select the number of Ships you want created here -->
        <actions>
Is there something else that can override these settings?

It works on gamestart, but I need it to be able to start mid-game as well.

There may be one other option. Having a interrupt handler to check key press data? Could you help me do that?

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Sun, 1. Jan 17, 12:54

Hotkeys are sadly not available except for some weird workarounds i dont want to explain here.

do you want to execute this script multiple times in the same game?
then you either have to reset the cue or instantiate it because each cue is usually only executed once.
(if you dont exactly know how instances in MD work i discourage the latter though - you can easily create leaks with this)

in short if you want to run it on gamestart and every load add a <reset_cue cue="this"/> to the actions of <cue name="CreateArawnFleets"
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

dwharper34
Posts: 22
Joined: Fri, 30. Dec 16, 01:08

Post by dwharper34 » Sun, 1. Jan 17, 14:05

I added <reset_cue cue="this"/> to the last line before </actions>.

I wanted to be able to create Arawn Fleets and Titurels after I build my stations for their upkeep missions, but not necessarily at the same time.

What if I were able to add a link to the SideBar and choose the options I wanted from there?

iforgotmysocks
Posts: 1244
Joined: Fri, 8. Nov 13, 22:35
x4

Post by iforgotmysocks » Sun, 1. Jan 17, 14:45

Then u'd have to turn the cue into a handler that catches the newly created menu-button push event and executes your code.

I suggest u take a look at the sidebarextender, thats an awesome extension for modders to easily add custom menu entries.

In the .lua file that u'll have to add to your mod u can create new menu entries and define a sectionprefix that u can look for, when u catch the event of the buttonpush in your handler.

This is an example for the handler in your md file:

Code: Select all

<cue name="My_SectionHandler" instantiate="false" namespace="default">
      <conditions>
        <check_any>
          <event_conversation_next_section sectionprefix="MyPrefix" />
          <event_conversation_returned_to_section sectionprefix="MyPrefix" />
        </check_any>
      </conditions>
      <actions>
<!-- your code -->
      </actions>
    </cue>

dwharper34
Posts: 22
Joined: Fri, 30. Dec 16, 01:08

Post by dwharper34 » Tue, 3. Jan 17, 03:58

iforgotmysocks wrote:
dwharper34 wrote: launching 2 scripts together
That doesn't work. Entities can only have one ai script running at a time. In this case the first script gets cancled and the second one is executed. So ya, go ahead and remove the second one. :)
I have another question. Using $ship.commander doesn't give the ship any orders.

Code: Select all

<assign_pilot actor="$ship_commander" object="$ship" />

<assign_defence_manager actor="$defenceNPC" object="$ship" />
<assign_engineer actor="$engineer" object="$ship" />
<!-- Here we want to make sure that our Yamatos are in the Arwans squad -->
<set_object_commander object="$ship" commander="global.$shipArawn" />
<!-- and escort it.-->

<start_script object="$ship.commander" name="'move.escort'">
   <param name="ship" value="global.$shipArawn"/>
</start_script>

<start_script object="$defenceNPC" name="'fight.defend.capital'" />
<start_script object="$engineer" name="'engineer.ai'" />
Changing $ship.commander to $ship.pilot does give the ship orders like below:

Code: Select all

<assign_pilot actor="$ship_commander" object="$ship" />

<assign_defence_manager actor="$defenceNPC" object="$ship" />
<assign_engineer actor="$engineer" object="$ship" />
<!-- Here we want to make sure that our Yamatos are in the Arwans squad -->
<set_object_commander object="$ship" commander="global.$shipArawn" />
<!-- and escort it.-->

<start_script object="$ship.pilot" name="'move.escort'">
   <param name="ship" value="global.$shipArawn"/>
</start_script>

   <!-- Should I put the line below back Here? -->

<start_script object="$defenceNPC" name="'fight.defend.capital'" />
<start_script object="$engineer" name="'engineer.ai'" />
My question is since I refer to the commander as pilot does that still refer to the same entity, the first line above makes me think it does, or does the line

Code: Select all

<start_script object="$ship_commander" name="'player.default'" />
need to be put back in?

Thanks again for all your help!

UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader » Tue, 3. Jan 17, 06:08

$ship.commander is another ship or station. what you probably want is $ship.commanderentity ;)
if not stated otherwise everything i post is licensed under WTFPL

Ich mache keine S&M-Auftragsarbeiten, aber wenn es fragen gibt wie man etwas umsetzen kann helfe ich gerne weiter ;)

I wont do Script&Mod Request work, but if there are questions how to do something i will GLaDly help ;)

dwharper34
Posts: 22
Joined: Fri, 30. Dec 16, 01:08

Post by dwharper34 » Tue, 3. Jan 17, 08:18

UniTrader wrote:$ship.commander is another ship or station. what you probably want is $ship.commanderentity ;)
I changed $ship.pilot to $ship.commanderentity and no orders were given. I don't use $ship.commander because it doesn't work for me either.

i'm going to change it back to $ship.pilot. Everything seems to work that way.

Thanks for the help!

Post Reply

Return to “X Rebirth - Scripts and Modding”