Buyable weapon modification parts - need help

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

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

KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Buyable weapon modification parts - need help

Post by KopiG »

Hello Guys!

I am trying to create a mod in which you could buy weapon modification parts at the Ship Equipment Vendor traders. The problem is I cannot figure out where that information is stored, which wares a Ship Equipment Vendor has.
Anybody could help me out please?
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

the file is called md/Setup.xml (i assume you already extracted the Game)

note that the actions performed there will only be executed on the start of a new Game, so changes there only work in this file. i suggest altering the List in a seperate MD Script with roughly this content:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="KopiG_Personal_cues" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
  <cues>
    <cue name="AddModPartsToTraders">
      <conditions>
        <check_any>
          <event_game_loaded/>
          <event_cue_completed cue="md.Setup.Start"/>
        </check_any>
      </conditions>
      <actions>
        <append_to_list list="md.$ShipTechLists.{1}" exact="[ware.***MOD_PART_WARE*****, 3, 6, 50]"/>
      </actions>
    </cue>
  </cues>
</mdscript>
exact values of the append_to_list have to be looked up - i just put in some filler stuff there..
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 ;)
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

Thank you very for your help UniTrader. Well since I am no way creating the new game I guess my mod is dead :) But thank you very much for the information. In case I will start a new game I will surely make my mod :)
w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans »

I think Uni meant that if you modify Setup.xml, your changes will only apply upon game start. But if you add stuff to the lists like how he showed you, it'll work upon game start and game load. And you could probably look up the lists in Setup.xml.

You're still very much in business.
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

Wow thank you! I misunderstood! I shall try it. Tho where do I have to put that new XML file?
w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans »

It would be a new file.

extensions\{YourModFolder}\md\{SomeFileName}.xml
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

So I have created it in those locations with this content:
md\addWeaponPartsToTrader.xml

Code: Select all

<?xml version="1.0" encoding="utf-8"?> 
<mdscript name="KopiG_Personal_cues" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd"> 
  <cues>
    <cue name="AddWeaponModPartsToTraders"> 
      <conditions> 
        <check_any> 
          <event_game_loaded/> 
          <event_cue_completed cue="md.Setup.Start"/> 
        </check_any> 
      </conditions> 
      <actions> 
        <append_to_list list="md.$ShipTechLists.{1}" exact="[ware.inv_weaponmodpart_t1, 3, 6, 100]"/>
		<append_to_list list="md.$ShipTechLists.{1}" exact="[ware.inv_weaponmodpart_t2, 3, 6, 100]"/>
		<append_to_list list="md.$ShipTechLists.{1}" exact="[ware.inv_weaponmodpart_t3, 3, 6, 100]"/>
      </actions> 
    </cue> 
  </cues> 
</mdscript> 
I enabled my mod and loaded up the game but it does not work :(
The way I tested it is that I contacted a vendor in space and asked for a trade. Or do I have to dock for this to work?
w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans »

strude posted some code here that does something similar:

http://forum.egosoft.com/viewtopic.php? ... 50#4596750

Maybe you'll have to go through variables as well? Although adding in lists directly should be possible, I would have thought.
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

Yeah I will try the variable way because it just doesnt work :(
EDIT: This does not work either :(

Code: Select all

<?xml version="1.0" encoding="utf-8"?> 
<mdscript name="KopiG_Personal_cues" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd"> 
  <cues>
    <cue name="AddWeaponModPartsToTraders"> 
      <conditions> 
        <check_any> 
          <event_game_loaded/> 
          <event_cue_completed cue="md.Setup.Start"/> 
        </check_any> 
      </conditions> 
      <actions>
	    <set_value name="$weaponModPartT1" exact="[ware.inv_weaponmodpart_t1, 3, 6, 100]" />
		<set_value name="$weaponModPartT2" exact="[ware.inv_weaponmodpart_t1, 3, 6, 100]" /> 
		<set_value name="$weaponModPartT3" exact="[ware.inv_weaponmodpart_t1, 3, 6, 100]" /> 
        <append_to_list list="md.$ShipTechLists.{1}" exact="$weaponModPartT1"/>
        <append_to_list list="md.$ShipTechLists.{1}" exact="$weaponModPartT2"/>
        <append_to_list list="md.$ShipTechLists.{1}" exact="$weaponModPartT3"/>
      </actions> 
    </cue> 
  </cues> 
</mdscript> 
Btw my I only have the content.xml file. No other files in the mod.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<content id="1.0" name="Buyable Weapon Mod Parts" description="You can buy Weapon Modification Party at the Ship Equipment Vendor" author="KopiG" version="1.0" save="false">
</content>
I took the ids from Roguey's site:
http://roguey.co.uk/xrebirth/wares/ware-135/
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

did you switch Zones after loading to create new NPCs? their Inventory is only set on their creation upon switching Zone context.
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 ;)
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

Yeah I have just tried it now. I switched zones/sectors even system. Flown from Devries to Albion but all Ship Equipment vendors sell the same stuff :( Weapon Mod Parts arent on their list :(
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

Please try this one and post the resulting logfile:

Code: Select all

<?xml version="1.0" encoding="utf-8"?> 
<mdscript name="KopiG_Personal_cues" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd"> 
  <cues>
    <cue name="AddWeaponModPartsToTraders"> 
      <conditions> 
        <check_any> 
          <event_game_loaded/> 
          <event_cue_completed cue="md.Setup.Start"/> 
        </check_any> 
      </conditions> 
      <actions>
        <debug_text filter="general" text="'Ware List Before:\n%1'.[ md.$ShipTechLists.{1} ]"/>
	    <set_value name="$weaponModPartT1" exact="[ware.inv_weaponmodpart_t1, 3, 6, 100]" />
		<set_value name="$weaponModPartT2" exact="[ware.inv_weaponmodpart_t1, 3, 6, 100]" /> 
		<set_value name="$weaponModPartT3" exact="[ware.inv_weaponmodpart_t1, 3, 6, 100]" /> 
        <append_to_list list="md.$ShipTechLists.{1}" exact="$weaponModPartT1"/>
        <append_to_list list="md.$ShipTechLists.{1}" exact="$weaponModPartT2"/>
        <append_to_list list="md.$ShipTechLists.{1}" exact="$weaponModPartT3"/>
        <debug_text filter="general" text="'Ware List After:\n%1'.[ md.$ShipTechLists.{1} ]"/>
      </actions> 
    </cue> 
  </cues> 
</mdscript> 

also keep in mind that in this form the Script is only executed once per Save/gamestart and changes made after that are not recognized.

Info on how to enable and find the debug log here:
https://www.egosoft.com:8444/confluence ... d=30113934
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 ;)
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

This is the file I used:

Code: Select all

<?xml version="1.0" encoding="utf-8"?> 
<mdscript name="KopiG_Personal_cues" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd"> 
  <cues> 
    <cue name="AddWeaponModPartsToTraders"> 
      <conditions> 
        <check_any> 
          <event_game_loaded/> 
          <event_cue_completed cue="md.Setup.Start"/> 
        </check_any> 
      </conditions> 
      <actions> 
      <debug_text filter="general" text="'Ware List Before:\n%1'.[ md.$ShipTechLists.{1} ]"/> 
      <set_value name="$weaponModPartT1" exact="[ware.inv_weaponmodpart_t1, 3, 6, 100]" /> 
      <set_value name="$weaponModPartT2" exact="[ware.inv_weaponmodpart_t2, 3, 6, 100]" /> 
      <set_value name="$weaponModPartT3" exact="[ware.inv_weaponmodpart_t3, 3, 6, 100]" /> 
        <append_to_list list="md.$ShipTechLists.{1}" exact="$weaponModPartT1"/> 
        <append_to_list list="md.$ShipTechLists.{1}" exact="$weaponModPartT2"/> 
        <append_to_list list="md.$ShipTechLists.{1}" exact="$weaponModPartT3"/> 
        <debug_text filter="general" text="'Ware List After:\n%1'.[ md.$ShipTechLists.{1} ]"/> 
      </actions> 
    </cue> 
  </cues> 
</mdscript>
This is the log result:

Code: Select all

Logfile started, time Sat Mar 12 16:17:56 2016
[General] 122842.65 ======================================
[=ERROR=] 122842.65 extensions\buyableWeapModParts\md\addWeaponPartsToTrader.xml(16): Required attribute 'name' is missing
[General] 122842.65 ======================================
[General] 122842.65 ======================================
[=ERROR=] 122842.65 extensions\buyableWeapModParts\md\addWeaponPartsToTrader.xml(16): append_to_list: Attribute list should not be used here
[General] 122842.65 ======================================
[General] 122842.65 ======================================
[=ERROR=] 122842.65 extensions\buyableWeapModParts\md\addWeaponPartsToTrader.xml(17): Required attribute 'name' is missing
[General] 122842.65 ======================================
[General] 122842.65 ======================================
[=ERROR=] 122842.65 extensions\buyableWeapModParts\md\addWeaponPartsToTrader.xml(17): append_to_list: Attribute list should not be used here
[General] 122842.65 ======================================
[General] 122842.65 ======================================
[=ERROR=] 122842.65 extensions\buyableWeapModParts\md\addWeaponPartsToTrader.xml(18): Required attribute 'name' is missing
[General] 122842.65 ======================================
[General] 122842.65 ======================================
[=ERROR=] 122842.65 extensions\buyableWeapModParts\md\addWeaponPartsToTrader.xml(18): append_to_list: Attribute list should not be used here
[General] 122842.65 ======================================
[General] 122865.08 ======================================
[=ERROR=] 122865.08 Error in AI script trade.performtraderun on entity 0xef3e: TradeID 1124: trade 390 Ore between Fedhelm and Integrative URV Forge failed with reasoncode 65536 (0x10000 - 0000000000000010000000000000000b)!
[General] 122865.08 ======================================
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

KopiG wrote:[/code]

This is the log result:

Code: Select all

Logfile started, time Sat Mar 12 16:17:56 2016
[General] 122842.65 ======================================
[=ERROR=] 122842.65 extensions\buyableWeapModParts\md\addWeaponPartsToTrader.xml(16): Required attribute 'name' is missing
[General] 122842.65 ======================================
[General] 122842.65 ======================================
[=ERROR=] 122842.65 extensions\buyableWeapModParts\md\addWeaponPartsToTrader.xml(16): append_to_list: Attribute list should not be used here
[General] 122842.65 ======================================
ah, my mistake.. the result Value / list where something has to be appended to is not list but name.. so basically changing all list= to name= and it should work ;)

I still wonder why the added debug outpud doesnt appear..
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 ;)
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

After the fix the vendor still does not have my wares and the log is pretty much empty this time :(

Code: Select all

<?xml version="1.0" encoding="utf-8"?> 
<mdscript name="KopiG_Personal_cues" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd"> 
  <cues> 
    <cue name="AddWeaponModPartsToTraders"> 
      <conditions> 
        <check_any> 
          <event_game_loaded/> 
          <event_cue_completed cue="md.Setup.Start"/> 
        </check_any> 
      </conditions> 
      <actions> 
      <debug_text filter="general" text="'Ware List Before:\n%1'.[ md.$ShipTechLists.{1} ]"/> 
      <set_value name="$weaponModPartT1" exact="[ware.inv_weaponmodpart_t1, 20, 20, 100]" /> 
      <set_value name="$weaponModPartT2" exact="[ware.inv_weaponmodpart_t2, 20, 20, 100]" /> 
      <set_value name="$weaponModPartT3" exact="[ware.inv_weaponmodpart_t3, 20, 20, 100]" /> 
        <append_to_list name="md.$ShipTechLists.{1}" exact="$weaponModPartT1"/> 
        <append_to_list name="md.$ShipTechLists.{1}" exact="$weaponModPartT2"/> 
        <append_to_list name="md.$ShipTechLists.{1}" exact="$weaponModPartT3"/> 
        <debug_text filter="general" text="'Ware List After:\n%1'.[ md.$ShipTechLists.{1} ]"/> 
      </actions> 
    </cue> 
  </cues> 
</mdscript>
The log file:

Code: Select all

Logfile started, time Sat Mar 12 16:40:27 2016
[General] 122865.20 ======================================
[=ERROR=] 122865.20 Error in AI script trade.performtraderun on entity 0xef3e: TradeID 1124: trade 390 Ore between Fedhelm and Integrative URV Forge failed with reasoncode 65536 (0x10000 - 0000000000000010000000000000000b)!
[General] 122865.20 ======================================
Its like it isnt executed? I am loading always the same file but of course never save it. Is that an issue?
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

I really cant get this to work. Anybody might have some info why/how to get this working?
Clownmug
Posts: 419
Joined: Wed, 11. Dec 13, 02:39
x4

Post by Clownmug »

I copied your script and tested in my game and it worked fine. Are you testing it with an old save file? The ship tech vendors won't be updated until you change zones if that's the case.
UniTrader
Moderator (Script&Mod)
Moderator (Script&Mod)
Posts: 14571
Joined: Sun, 20. Nov 05, 22:45
x4

Post by UniTrader »

sorry i didnt reply yet - i have lost track of this topic..
i just copied the Code above into my Game and it worked... the Message appeared in the Log (hidden by dozens of other messages.. didnt test/clean my current WiP Script yet :D ) and the Wares were also immediately buy-able in a new Game on the first random Ship Technican i could contact..should be the same for Savegames after a Zone switch (if this Script wasnt used before in thsi save; couldnt test the save case because i dont have one at hand).. so no idea whats wrong there..

could you put this line somewhere into actions and tell us if it throws any errors:
<set_value name="no idea" exact="blah blah blah"/>
(putting invalid code somewhere is imo a good way to make sure the code is read/used at all)
This should cause multiple errors in the log - two when reading the file and one or two more on execution....
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 ;)
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

Clownmug wrote:I copied your script and tested in my game and it worked fine. Are you testing it with an old save file? The ship tech vendors won't be updated until you change zones if that's the case.
This is the strange part. I do change zones... even Sectors like from DeVries to Albion
KopiG
Posts: 270
Joined: Sat, 16. Nov 13, 11:07
x4

Post by KopiG »

Okay I started out a new game and the mod is working perfectly fine with the mods I installed. What could be the problam? Somewhere I read I think that these "cues" are instanceiated only once and keep running even if the mod is taken out. Could this be the case that the non functioning cue got stuck in my save file?
Renamed the cue's name but nothing changed. The ware list is not updated.

Return to “X Rebirth - Scripts and Modding”