How do i add wares to a trader

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

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

Post Reply
User avatar
ADMNtek
Posts: 345
Joined: Tue, 7. May 13, 16:07
x4

How do i add wares to a trader

Post by ADMNtek » Sun, 25. Sep 16, 05:43

this might be a stupid question but i have bin googling and looking in this forum but i cant seem to find the right anwer. so please can someone tell me how i add new wares to a trader.
i made a new missile but i cant add it to the trader. i know it has to do with the NPC_Itemtrader.xml but i cant make heads or tails of that one.

also how do i calculate range and Acceleration Time for the T file.

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Mon, 26. Sep 16, 21:54

think you're looking for md\Setup.xml. this bit:

Code: Select all

        <set_value name="md.$ArmsDealerLists" exact="
            [
                [
                    [ware.spe_ammo_dumbfiremissile, 20, 40, 90],
                    [ware.spe_ammo_dumbfiremissile_h, 8, 16, 70],
                    [ware.spe_ammo_guidedmissile_l, 18, 36, 90],
                    [ware.spe_ammo_guidedmissile, 16, 32, 80],
                    [ware.spe_ammo_guidedmissile_h, 6, 12, 70],
                    [ware.spe_ammo_swarmmissile, 4, 8, 70],
                    [ware.spe_ammo_swarmmissile_h, 2, 4, 60],
                    [ware.spe_ammo_torpedo, 2, 4, 50],
                    [ware.spe_ammo_empmissile, 0, 0, 0],
                    [ware.spe_ammo_torpedo_02, 0, 0, 0]
                ]
            ]
        "/>
from cue name="Start"

problem is, i'm pretty sure that cue only ever runs once per game, so adding to that list will require a new game start. you could patch it in, but that could break horribly if a new game update is ever done and that cue were also patched by the update. compatibility issues if anyone else ever patches the same cue as well. without patching, think you should be able to just add your new missile into that list.
ADMNtek wrote:also how do i calculate range and Acceleration Time for the T file.
sorry, not sure what you mean. do you mean the range and acceleration time of the missile? that should be in the asset macro of the missile. something like:

Code: Select all

<missile amount="1" lifetime="12" guided="1" icon="player_weapons_secondary_starflash" retarget="1" selfdestruct="1" />
that's from assets\fx\weaponfx\macros\missile_player_guided_light_macro.xml

edit: sorry, forgot you wanted range. that's defined by the acceleration, speed, and lifetime of the missile. acceleration and speed are defined on the missile engine. in this case, assets\props\EngineSystems\macros\engine_missile_player_guided_l_macro:

Code: Select all

<acceleration forward="270" reverse="270" strafe="360" pitch="180" yaw="180" roll="180" />
...
<speed forward="775" reverse="0" strafe="0" pitch="360" yaw="360" roll="360" />
forward acceleration is 270 m/s^2, up to a top speed of 775 m/s, and the missile lasts for 12 seconds. missile accelerates for 2.87ish seconds in which it travels (if my math is correct) around 1112 meters. cruises for 9.13 seconds at top speed, so max range is around 8188 meters.

User avatar
ADMNtek
Posts: 345
Joined: Tue, 7. May 13, 16:07
x4

Post by ADMNtek » Tue, 27. Sep 16, 00:35

my setup.xml now look like this is that correct.

Code: Select all

<?xml version="1.0" encoding="utf-8"?>

<diff>
	<add sel="/mdscript/cues/cue[@name='Start']/actions/set_value[@name='md.$ArmsDealerLists']">
        <set_value name="md.$ArmsDealerLists" exact="
            [
                [
                    [ware.spe_ammo_swarmmissile_jericho, 25, 50, 80],
                ]
            ]
        "/>
	</add>
</diff>
and thanks for the other info cant believe i didn't come up with that :oops: .

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Tue, 27. Sep 16, 18:55

my md's rusty, but i think that'll replace the lists of all arms dealers so they'll only ever sell your missile. come to think of it, this should be more like what you wanted:

Code: Select all

<?xml version="1.0" encoding="utf-8"?>
<mdscript name="ADMNtek_init" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
	<cues>
		<cue name="init_MissileTraders">
			<conditions>
				<check_any>
					<event_cue_completed cue="md.Setup.Start"/>
					<event_game_loaded/>
				</check_any>
			</conditions>
			<actions>
				<do_all exact="md.$ArmsDealerLists.count" counter="$i">
					<append_to_list name="md.$ArmsDealerLists.{$i}" exact="[ware.spe_ammo_swarmmissile_jericho, 25, 50, 80]"/>
				</do_all>
			</actions>
		</cue>
	</cues>
</mdscript>
placed in a file called "ADMNtek_init.xml" in the md folder. that should add your missile to all Arms Dealer lists once, regardless of whether it's a new game start or an existing game. should be compatible with any mods that add missiles as well, unless they overwrite the entire list. in the last case, you could just make sure that your cue loads after the incompatible mod.

could also make it so that it checks every time a game starts to see if your missile was already added and, if not, add it. let me know if you want to go that route.

not the only way to do this, of course, and not sure if it's the best way. but should work.

User avatar
ADMNtek
Posts: 345
Joined: Tue, 7. May 13, 16:07
x4

Post by ADMNtek » Tue, 27. Sep 16, 21:39

:o thank you man that worked like a charm. next step get them to show up in my ships inventory. must have messed up somewhere.

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Tue, 27. Sep 16, 21:58

think you have to add your missile to the player ship macros. those are in assets\units\player\macros\unit_player_ship_a_macro.xml, unit_player_ship_b_macro.xml, and unit_player_ship_c_macro.xml. (no idea why there are three of them.) under <slot ref="weaponconnection3"> and/or <slot ref="weaponconnection4">.

and don't forget to register your missile macro in index\macros.xml.

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

Post by UniTrader » Tue, 27. Sep 16, 22:19

w.evans wrote:think you have to add your missile to the player ship macros. those are in assets\units\player\macros\unit_player_ship_a_macro.xml, unit_player_ship_b_macro.xml, and unit_player_ship_c_macro.xml. (no idea why there are three of them.)
one for each possible starting CP ;) (during the Game the Ship Macro will remain unchanged, jut the CP Macro is swapped - but this way the starting CP is defined)
there is btw also a fourth one with a slightly diffrent name (i think it was build)
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 ;)

User avatar
ADMNtek
Posts: 345
Joined: Tue, 7. May 13, 16:07
x4

Post by ADMNtek » Tue, 27. Sep 16, 22:48

i did currently look like this. i tried with just one and with both connections.


Code: Select all

<diff>
  <add sel="/macros/macro/properties/weapons">
    <slot ref="weaponconnection3">
       <cycle index="11" ref="missile_player_swarm_jericho_macro" />
    </slot>
	<slot ref="weaponconnection4">
	   <cycle index="11" ref="missile_player_swarm_jericho_macro" />
	</slot>
  </add>
</diff>
and i have this in my macros xml

Code: Select all

<diff>
  <add sel="/index">
	<entry name="missile_player_swarm_jericho_macro" value="extensions\JerichoMissileMod\assets\fx\weaponfx\macros\missile_player_swarm_jericho_macro"/>
	<entry name="engine_missile_player_swarm_jericho_macro" value="extensions\JerichoMissileMod\assets\props\EngineSystems\macros\engine_missile_player_swarm_jericho_macro"/>
	<entry name="wrs_jericho_macro" value="extensions\JerichoMissileMod\assets\wares\macros\wrs_jericho_macro"/>
	</add>
</diff>
Last edited by ADMNtek on Wed, 28. Sep 16, 22:48, edited 2 times in total.

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Wed, 28. Sep 16, 18:25

Code: Select all

<diff>
  <add sel="/macros/macro/properties/weapons/slot[@ref='weaponconnection3']">
    <cycle index="11" ref="missile_player_swarm_jericho_macro"/>
  </add>
  <add sel="/macros/macro/properties/weapons/slot[@ref='weaponconnection4']">
    <cycle index="11" ref="missile_player_swarm_jericho_macro"/>
  </add>
</diff>
should do it.

or you could shorten the paths to:

Code: Select all

<diff>
  <add sel="//slot[@ref='weaponconnection3']">
    <cycle index="11" ref="missile_player_swarm_jericho_macro"/>
  </add>
  <add sel="//slot[@ref='weaponconnection4']">
    <cycle index="11" ref="missile_player_swarm_jericho_macro"/>
  </add>
</diff>
since it looks like the two "slot" nodes are unique in those files with the "ref" connections specified.

User avatar
ADMNtek
Posts: 345
Joined: Tue, 7. May 13, 16:07
x4

Post by ADMNtek » Wed, 28. Sep 16, 22:47

Duurr
OK why does it works when i start a new game. i can buy i can fire everything works like it should butt it does not work on an existing save.
however i found a mod (ExploreAndSalvage) that adds a new weapon and there it works on old saves :? .

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

Post by UniTrader » Wed, 28. Sep 16, 23:20

did you use an existing save from before starting experimenting? maybe you made a mistake initially where the cue triggered but didnt do anything, saved afterwards and now you load a save where this cue is complete and doesnt trigger again?

anyway, best post all you have currently, so we dont have to guess into the blue
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 ;)

User avatar
ADMNtek
Posts: 345
Joined: Tue, 7. May 13, 16:07
x4

Post by ADMNtek » Thu, 29. Sep 16, 01:23

i tried it on several saves. including some from long befor i even started with this.

this is the current version.
https://drive.google.com/open?id=0B-hvX ... VdPY1IxcFk

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Fri, 30. Sep 16, 18:58

which part doesn't work when loading? can't buy your missile at traders? they won't load at the Skunk? they don't work? or they don't do what you expected them to?

i suspect the first, but would be good to confirm.

if the first, would you be willing to work with a save from before you started working on the mod? (also possible to fix if not, but just a tiny bit more complicated.)

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

Post by UniTrader » Fri, 30. Sep 16, 19:07

another idea: did you change the Zone after adding the Mod? because the Traders are created on Zone change with their Inventory based on the Values you changed - but if they are Already created they wont update, so you have to change the Zone after adding the Mod...
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 ;)

User avatar
ADMNtek
Posts: 345
Joined: Tue, 7. May 13, 16:07
x4

Post by ADMNtek » Sat, 1. Oct 16, 00:17

they won´t load into the skunk i can buy them no problem. but they dont show up in my missile list.
and i have tried an old save it did not work. but when i start a new game it works.

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Sat, 1. Oct 16, 07:08

right. because we changed the Skunk's macro, and the old macro is saved in the save file. changing cockpits might sort you out, but am not sure. might require a new game after all.

User avatar
ADMNtek
Posts: 345
Joined: Tue, 7. May 13, 16:07
x4

Post by ADMNtek » Sat, 1. Oct 16, 10:43

but i have used other mods that have changed that macro they work fine.
changing the cockpit had no effect.

w.evans
Posts: 2963
Joined: Tue, 18. Nov 14, 16:23
x4

Post by w.evans » Sat, 1. Oct 16, 12:34

in that case, i'm out of ideas. only thing i could suggest is to check those mods and see how they got the changes in.

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

Post by UniTrader » Sat, 1. Oct 16, 12:36

i would guess a <patch_macro object="player.primaryship"/> in the actions of your ware adding script might help ;)
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 ;)

User avatar
ADMNtek
Posts: 345
Joined: Tue, 7. May 13, 16:07
x4

Post by ADMNtek » Sat, 1. Oct 16, 14:43

you might think that but nope nothing.:cry: or i added it wrong.

tried it like this

Code: Select all

<mdscript name="ADMNtek_init" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
   <cues>
      <cue name="init_MissileTraders">
         <conditions>
            <check_any>
               <event_cue_completed cue="md.Setup.Start"/>
               <event_game_loaded/>
            </check_any>
         </conditions>
         <actions>
            <do_all exact="md.$ArmsDealerLists.count" counter="$i">
			   <patch_macro object="player.primaryship"/>
               <append_to_list name="md.$ArmsDealerLists.{$i}" exact="[ware.spe_ammo_swarmmissile_jericho, 25, 50, 80]"/>
            </do_all>
         </actions>
      </cue>
   </cues>
</mdscript>
and like this

Code: Select all

<mdscript name="ADMNtek_init" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="md.xsd">
   <cues>
      <cue name="init_MissileTraders">
         <conditions>
            <check_any>
               <event_cue_completed cue="md.Setup.Start"/>
               <event_game_loaded/>
            </check_any>
         </conditions>
         <actions>
         <patch_macro object="player.primaryship"/>
            <do_all exact="md.$ArmsDealerLists.count" counter="$i">
			   <patch_macro object="player.primaryship"/>
               <append_to_list name="md.$ArmsDealerLists.{$i}" exact="[ware.spe_ammo_swarmmissile_jericho, 25, 50, 80]"/>
            </do_all>
         </actions>
      </cue>
   </cues>
</mdscript>

Post Reply

Return to “X Rebirth - Scripts and Modding”