create_station is putting wrong buildlocation attribute in stations it builds

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

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

jth
Posts: 296
Joined: Tue, 3. Jan 06, 23:31
x3

create_station is putting wrong buildlocation attribute in stations it builds

Post by jth »

I have been trying to use the create_station APi call to cleanly re-create user stations.

They create fine but when I go to "Deploy to station" a new CV then that CV vanishes. It produces an error

[=ERROR=] Failed to connect component 'units_size_xl_builder_ship_macro' to 'tzonecluster_d_sector18_zone46_macro'. Child template connection not specified

I dug a bit deeper into NPC_Architect and $DeployedStation.buildlocation wasn't pointing at the correct buildlocation which causes the CV to fail to attach to the zone and hence vanish.

A station created with construct_station gets the buildlocation attribute right and you can "Deploy to station" a new CV

I wrote a testing script that creates a station every time you talk to a station Control Entity

When it finds somewhere free to build then it outputs some messages

[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:193f6>: random zone 3 Magma Pool
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:193f6>: Free Build location <componentmacroslot:0x230e,buildcon1>
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:193f6>: Actual build location <componentmacroslot:0x230e,struct_bt_dv_canteran_outpost_02_macro>

[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:197d8>: random zone 9 Furnace Chamber
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:197d8>: Free Build location <componentmacroslot:0x343b,buildcon1>
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:197d8>: Actual build location <componentmacroslot:0x343b,struct_bt_dv_water_destillery_macro>

[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:19f0a>: random zone 4 Fervid Corona
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:19f0a>: Free Build location <componentmacroslot:0x2472,buildcon2>
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:19f0a>: Actual build location <componentmacroslot:0x2472,struct_econ_unique_ar_spp_xl_macro>

[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:2055c>: random zone 2 Scorched Aura
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:2055c>: Free Build location <componentmacroslot:0x2171,buildcon1>
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:2055c>: Actual build location <componentmacroslot:0x2171,NULL>

Looking at that it seems to be putting the macro of the first NPC station in the zone into the buildlocation attribute or NULL if there isn't one

Its a bit of a show stopper :( any chance of a fix please ?

Code: Select all

    <cue name="TestTrigger" namespace="this" instantiate="true" >
      <conditions>
        <check_any>
          <event_conversation_started conversation="default" />
          <event_conversation_returned_to_section section="default" />
        </check_any>
        <check_value value="event.object.container.class == class.station"/>
        <check_value value="event.object.iscontrolentity" />
      </conditions>
      <actions>
         <signal_cue_instantly cue="Test_Create_Station"/>
      </actions>
    </cue>

    <cue name="Test_Create_Station" namespace="this" instantiate="true" comment="builds dummy stations">
      <conditions>
        <event_cue_signalled/>
      </conditions>
      <actions>
        <find_sector name="$DV_CanteranSec" macro="macro.cluster_d_sector18_macro" space="md.$DeVries" required="true"/>
        <find_zone name="$CanteranZones" space="$DV_CanteranSec" multiple="true" priorityzone="true" tempzone="false"/>
        <set_value name="$RandZone" min="1" max="$CanteranZones.count" profile="flat"/>
        <debug_text text="'random zone ' + $RandZone + ' ' + $CanteranZones.{$RandZone}.name"/>
        <set_value name="$BuildIn" exact="$CanteranZones.{$RandZone}.name"/>
        <do_if value="($CanteranZones.{$RandZone}.freebuildlocations.count ge 1)" >
          <set_value name="$BuildLocation" exact="$CanteranZones.{$RandZone}.freebuildlocations.random"/>
          <set_value name="$results" exact="'Free build location ' + @$BuildLocation + '\n'"/>
          <debug_text text="'Free Build location ' + $BuildLocation"/>
        </do_if>
        <do_else>
          <set_value name="$results" exact="'No - Free Build location'"/>
          <show_notification caption="$BuildIn" details="[$results]" timeout="3s" queued="false"/>
          <remove_value name="$BuildLocation"/>
        </do_else>

        <do_if value="@$BuildLocation">
          <set_value name="$BuildMacro" exact="macro.struct_bt_alb_farm_complex_macro" />

          <create_station name="$playerstation" macro="$BuildMacro" zone="$BuildLocation.component" owner="faction.player">
            <position value="$BuildLocation.offset"/>
            <buildsequence sequence="'a'" stage="1"/>
          </create_station>
          
          <debug_text text="'Actual build location ' + $playerstation.buildlocation"/>
          <set_value name="$results" exact="$results + 'Actual build location ' + $playerstation.buildlocation"/>
          <show_notification caption="$BuildIn" details="[$results]" timeout="10s" queued="false"/>

        </do_if>
      </actions>
    </cue>

regards

jth
User avatar
Marvin Martian
Posts: 3614
Joined: Sun, 8. Apr 12, 09:40
x4

Post by Marvin Martian »

i think you need

Code: Select all

<claim_build_location object="$playerstation" buildlocation="$BuildLocation"/>
after the station is created, otherwise the Buildlocation is already free
jth
Posts: 296
Joined: Tue, 3. Jan 06, 23:31
x3

Post by jth »

Marvin Martian wrote:i think you need

Code: Select all

<claim_build_location object="$playerstation" buildlocation="$BuildLocation"/>
after the station is created, otherwise the Buildlocation is already free
Good thought

I modified the code to try it three different ways

Code: Select all

          <create_station name="$playerstation" macro="$BuildMacro" zone="$BuildLocation.component" owner="faction.player">
            <position value="$BuildLocation.offset"/>
            <buildsequence sequence="'a'" stage="1"/>
          </create_station>
          <claim_build_location object="$playerstation" buildlocation="$BuildLocation"/>

          <claim_build_location object="$playerstation" buildlocation="$BuildLocation"/>
          <create_station name="$playerstation" macro="$BuildMacro" zone="$BuildLocation.component" owner="faction.player">
            <position value="$BuildLocation.offset"/>
            <buildsequence sequence="'a'" stage="1"/>
          </create_station>
          <remove_build_location_claim buildlocation="$BuildLocation"/>

          <claim_build_location object="$playerstation" buildlocation="$BuildLocation"/>
          <create_station name="$playerstation" macro="$BuildMacro" zone="$BuildLocation.component" owner="faction.player">
            <position value="$BuildLocation.offset"/>
            <buildsequence sequence="'a'" stage="1"/>
          </create_station>

and its still putting the wrong stuff into the buildlocation attribute :(

[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:45ac9>: random zone 8 Darned Hot Air
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:45ac9>: Free Build location <componentmacroslot:0x2f6c6,buildcon2>
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:45ac9>: Actual build location <componentmacroslot:0x2f6c6,struct_bt_dv_shipyard_macro>

[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:46483>: random zone 7 Gushing Spring
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:46483>: Free Build location <componentmacroslot:0x2f006,buildcon1>
[Scripts] *** Context:md.StationStructuralRebuild.Test_Create_Station<inst:46483>: Actual build location <componentmacroslot:0x2f006,struct_bt_dv_home_station_macro>

I think that claim_build_location and remove_build_location_claim are more to do with preventing two CV's from trying for the same build location at the same time

jth
User avatar
Marvin Martian
Posts: 3614
Joined: Sun, 8. Apr 12, 09:40
x4

Post by Marvin Martian »

hmmm unexpected
jth wrote:I think that claim_build_location and remove_build_location_claim are more to do with preventing two CV's from trying for the same build location at the same time
but connect_to_build_location & disconnect_from_build_location is for that

so the claim thing could be used on Shipyards maybe?

---
edit:
take look into md/Setup_Gamestarts.xml, Ep1Build is building a Station
Xenon_Slayer
EGOSOFT
EGOSOFT
Posts: 13125
Joined: Sat, 9. Nov 02, 11:45
x4

Post by Xenon_Slayer »

It does seem that using create_station will not connect it to the buildlocation which you attempted to place it on. It may actually be causing issues with the gamestart station if you ever wanted to replace the Construction Vessel.

I'll take a look at improving the create_station action so you can pass the build location in.

The only way to get around it would be to have a Construction Vessel actually construct it from scratch.
jth
Posts: 296
Joined: Tue, 3. Jan 06, 23:31
x3

Post by jth »

Marvin Martian wrote:hmmm unexpected
jth wrote:I think that claim_build_location and remove_build_location_claim are more to do with preventing two CV's from trying for the same build location at the same time
but connect_to_build_location & disconnect_from_build_location is for that

so the claim thing could be used on Shipyards maybe?

---
edit:
take look into md/Setup_Gamestarts.xml, Ep1Build is building a Station
connect_to_build_location & disconnect_from_build_location are for attaching and detaching a builder CV to/from a station. I did try to connect_to_build_location $playerstation but got back a message saying object is not a CV. basically builder CV's connect_to_build_location and stations are built on a specific buildlocation.

Shipyards run a variation on the NPC_Architect script and NPC_Shiptrader contains the words architect in a number of places. What they have in common is that they both use build modules. For the architect its contained in the builder Cv and for the station ShipDealer its their ship production module.

The problem that I have is that although it builds the station OK it doesn't set the buildlocation properly so I can't Deploy a CV to it as NPC_Architect fails when it tries to

<connect_to_build_location object="$actor.container" buildlocation="$DeployedStation.buildlocation"/>

and the reason that it fails is that $DeployedStation.buildlocation is wrong as it is not being set correctly when the station is created by create_station

There is also a very good example of station building in Plot_ep1_ch2.xml in the CreatePlayerStation library

jth
User avatar
Marvin Martian
Posts: 3614
Joined: Sun, 8. Apr 12, 09:40
x4

Post by Marvin Martian »

Xenon_Slayer wrote:I'll take a look at improving the create_station action so you can pass the build location in.
why not connect the CV to the Station directly in that case instead of an unhandy Buildlocation?
maybe with creating an new buildlocation on the station place?

It would make more sense relating to Modding and the possibility to script stations, get ownership of NPC Stations and anything else
jth
Posts: 296
Joined: Tue, 3. Jan 06, 23:31
x3

Post by jth »

Xenon_Slayer wrote:It does seem that using create_station will not connect it to the buildlocation which you attempted to place it on. It may actually be causing issues with the gamestart station if you ever wanted to replace the Construction Vessel.

I'll take a look at improving the create_station action so you can pass the build location in.

The only way to get around it would be to have a Construction Vessel actually construct it from scratch.
Thanks for confirming that.

If I create the CV first and then use the construct_station API call then it will take a very long time for a big station :( which I am trying to avoid.

The ability to pop the new station on top of the old one instantly is what I am looking for. If I have to delete the old one first then I could do but having them both exist at the same times makes it easier to script the cloning of the original.

Thanks

jth
Xenon_Slayer
EGOSOFT
EGOSOFT
Posts: 13125
Joined: Sat, 9. Nov 02, 11:45
x4

Post by Xenon_Slayer »

In an upcoming build, create_station will have a 'buildlocation' attribute. You'll still need to set the position as you are now, but $station.buildlocation will give you the right connection.

Thanks for finding this, it was also causing issues with the station in the build gamestart, which is now also fixed.

Return to “X Rebirth - Scripts and Modding”