[ADVICE REQ] Syntax for removing parameters

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

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

argon_emperor
Posts: 1225
Joined: Mon, 12. Dec 05, 07:41
x4

[ADVICE REQ] Syntax for removing parameters

Post by argon_emperor »

So I'm trying to edit the shipgroups.xml to allow Scaleplate to use *any* s or m combat ship, rather than just a select few (they're pirates after all, they just take what they want, no need to be limited :P ), but I also want them all to be an even chance of spawning

So currently in the sca_pirate_sm & sca_pirate_s groups, the existing ship selections have weights. I know I can just add new ships to choose from with (at least 98% sure I have the right syntax here, correct me if I'm wrong

Code: Select all

<add sel="/groups/group[@name='sca_pirate_sm'/]>
	<select macro="{insert new ship selection macro here}/>
</add>
Now I think to remove the "weight" attribute that's on the same line as the select/macro line that's currently existing I need to do the following:

Code: Select all

<remove sel="/groups/group[@name='sca_pirate_sm']/select[@macro='ship_arg_m_bomber_02_a_macro']/@weight" />
But in all honesty, still quite new at xml editing and I can't help that think I'm reading this wrong, so just wanting some advice from better skilled peeps XD Does this look correct?

Original node for reference:

Code: Select all

<groups>
  <group name="sca_pirate_sm">
    <select macro="ship_arg_m_bomber_02_a_macro" weight="1"/>
    <select macro="ship_arg_s_scout_01_a_macro" weight="36"/>
    <select macro="ship_arg_s_scout_01_b_macro" weight="36"/>
    <select macro="ship_tel_s_scout_01_a_macro" weight="54"/>
    <select macro="ship_tel_s_scout_01_b_macro" weight="54"/>
    <select macro="ship_tel_s_fighter_01_a_macro" weight="9"/>
    <select macro="ship_tel_s_fighter_01_b_macro" weight="9"/>
  </group>
</groups>
[ external image ]
***modified***
"You can get more of what you want with kind words and a gun, than you can with just kind words" - Al Capone
argon_emperor
Posts: 1225
Joined: Mon, 12. Dec 05, 07:41
x4

Re: [ADVICE REQ] Syntax for removing parameters

Post by argon_emperor »

Okay, so I can't even get the adding part right it seems

Code: Select all

  <!-- ############################# -->
  <!--    SCALEPLATE PACT  -->
  <!--      (sometimes also used by Hatikvah jobs) -->
  <!-- #############################
  <group name="sca_pirate">
    <select macro="ship_arg_m_bomber_02_a_macro"/>
  </group>

  <group name="sca_pirate_sm">
    <select macro="ship_arg_m_bomber_02_a_macro" weight="1"/>
    <select macro="ship_arg_s_scout_01_a_macro" weight="36"/>
    <select macro="ship_arg_s_scout_01_b_macro" weight="36"/>
    <select macro="ship_tel_s_scout_01_a_macro" weight="54"/>
    <select macro="ship_tel_s_scout_01_b_macro" weight="54"/>
    <select macro="ship_tel_s_fighter_01_a_macro" weight="9"/>
    <select macro="ship_tel_s_fighter_01_b_macro" weight="9"/>
  </group>

  <group name="sca_pirate_s">
    <select macro="ship_arg_s_scout_01_a_macro" weight="30"/>
    <select macro="ship_arg_s_scout_01_b_macro" weight="30"/>
    <select macro="ship_tel_s_scout_01_a_macro" weight="70"/>
    <select macro="ship_tel_s_scout_01_b_macro" weight="70"/>
    <select macro="ship_tel_s_fighter_01_a_macro" weight="1"/>
    <select macro="ship_tel_s_fighter_01_b_macro" weight="1"/>
  </group> -->

<diff>
	<add sel="groups/group[@name='sca_pirate']" />
		<select macro="ship_arg_m_bomber_01_a_macro"/>
		<select macro="ship_arg_m_bomber_01_b_macro"/>
		<select macro="ship_arg_m_frigate_01_a_macro"/>
		<select macro="ship_arg_m_frigate_01_b_macro"/>
		<select macro="ship_par_m_corvette_01_a_macro"/>
		<select macro="ship_par_m_corvette_01_b_macro"/>
		<select macro="ship_par_m_frigate_01_a_macro"/>
		<select macro="ship_par_m_frigate_01_b_macro"/>
		<select macro="ship_tel_m_bomber_01_a_macro"/>
		<select macro="ship_tel_m_bomber_01_b_macro"/>
		<select macro="ship_tel_m_frigate_01_a_macro"/>
		<select macro="ship_tel_m_frigate_01_b_macro"/>
	</add>
	<add sel="groups/group[@name='sca_pirate_sm']" />
		<select macro="ship_arg_m_bomber_01_a_macro"/>
		<select macro="ship_arg_m_bomber_01_b_macro"/>
		<select macro="ship_arg_m_frigate_01_a_macro"/>
		<select macro="ship_arg_m_frigate_01_b_macro"/>
		<select macro="ship_par_m_corvette_01_a_macro"/>
		<select macro="ship_par_m_corvette_01_b_macro"/>
		<select macro="ship_par_m_frigate_01_a_macro"/>
		<select macro="ship_par_m_frigate_01_b_macro"/>
		<select macro="ship_tel_m_bomber_01_a_macro"/>
		<select macro="ship_tel_m_bomber_01_b_macro"/>
		<select macro="ship_tel_m_frigate_01_a_macro"/>
		<select macro="ship_tel_m_frigate_01_b_macro"/>
		<select macro="ship_arg_s_fighter_01_a_macro"/>
		<select macro="ship_arg_s_fighter_01_b_macro"/>
		<select macro="ship_arg_s_fighter_02_a_macro"/>
		<select macro="ship_arg_s_fighter_02_b_macro"/>
		<select macro="ship_arg_s_fighter_03_a_macro"/>
		<select macro="ship_arg_s_fighter_04_a_macro"/>
		<select macro="ship_arg_s_heavyfighter_01_a_macro"/>
		<select macro="ship_arg_s_heavyfighter_01_b_macro"/>
		<select macro="ship_arg_s_heavyfighter_02_a_macro"/>
		<select macro="ship_par_s_fighter_01_a_macro"/>
		<select macro="ship_par_s_fighter_01_b_macro"/>
		<select macro="ship_par_s_fighter_02_a_macro"/>
		<select macro="ship_par_s_fighter_02_b_macro"/>
		<select macro="ship_par_s_scout_01_a_macro"/>
		<select macro="ship_par_s_scout_01_b_macro"/>
		<select macro="ship_tel_s_fighter_02_a_macro"/>
		<select macro="ship_tel_s_fighter_02_b_macro"/>
		<select macro="ship_tel_s_scout_02_a_macro"/>
		<select macro="ship_tel_s_scout_02_b_macro"/>
	</add>
	<add sel="groups/group[@name='sca_pirate_s']" />
		<select macro="ship_arg_s_fighter_01_a_macro"/>
		<select macro="ship_arg_s_fighter_01_b_macro"/>
		<select macro="ship_arg_s_fighter_02_a_macro"/>
		<select macro="ship_arg_s_fighter_02_b_macro"/>
		<select macro="ship_arg_s_fighter_03_a_macro"/>
		<select macro="ship_arg_s_fighter_04_a_macro"/>
		<select macro="ship_arg_s_heavyfighter_01_a_macro"/>
		<select macro="ship_arg_s_heavyfighter_01_b_macro"/>
		<select macro="ship_arg_s_heavyfighter_02_a_macro"/>
		<select macro="ship_par_s_fighter_01_a_macro"/>
		<select macro="ship_par_s_fighter_01_b_macro"/>
		<select macro="ship_par_s_fighter_02_a_macro"/>
		<select macro="ship_par_s_fighter_02_b_macro"/>
		<select macro="ship_par_s_scout_01_a_macro"/>
		<select macro="ship_par_s_scout_01_b_macro"/>
		<select macro="ship_tel_s_fighter_02_a_macro"/>
		<select macro="ship_tel_s_fighter_02_b_macro"/>
		<select macro="ship_tel_s_scout_02_a_macro"/>
		<select macro="ship_tel_s_scout_02_b_macro"/>
	</add>
</diff>
This is what I've tried using (top part is the original for reference), and not only have I not seen a single Scaleplate ship other than the normal ones spawn, I'm actually seeing a lot LESS of them spawning at all, as if I've somehow broken their spawning with this... :S

Any help would be much appreciated :)
[ external image ]
***modified***
"You can get more of what you want with kind words and a gun, than you can with just kind words" - Al Capone
A.Persyn
Posts: 121
Joined: Sun, 14. Mar 10, 13:14
x3tc

Re: [ADVICE REQ] Syntax for removing parameters

Post by A.Persyn »

With shipgroups the default weight is 100. If the weight is less than 100, ships may sometimes not spawn at all. Only one ship from the group will be chosen.
EDIT: if you break a DIFF XML it will log it in the debug log file. To see if the changes are working, create a new job (jobs.xml) that spawns the ship in a predictable location.
argon_emperor
Posts: 1225
Joined: Mon, 12. Dec 05, 07:41
x4

Re: [ADVICE REQ] Syntax for removing parameters

Post by argon_emperor »

A.Persyn wrote: Wed, 12. Dec 18, 18:04 With shipgroups the default weight is 100. If the weight is less than 100, ships may sometimes not spawn at all. Only one ship from the group will be chosen.
EDIT: if you break a DIFF XML it will log it in the debug log file. To see if the changes are working, create a new job (jobs.xml) that spawns the ship in a predictable location.
Well, turning on the debug file already helped with first error... On the <add> line, I had </> at the end without even thinking, causing the </add> after the group to try to match up with the <diff> at the start... Stupid mistake XD

But after fixing that, its' giving me the following errors now

Code: Select all

[=ERROR=] 0.00 No matching node for path 'groups/group[@name='sca_pirate']' in patch file 'extensions\ScalePlate Use All\libraries\shipgroups'. Skipping node.
 [=ERROR=] 0.00 No matching node for path 'groups/group[@name='sca_pirate_sm']' in patch file 'extensions\ScalePlate Use All\libraries\shipgroups'. Skipping node.
 [=ERROR=] 0.00 No matching node for path 'groups/group[@name='sca_pirate_s']' in patch file 'extensions\ScalePlate Use All\libraries\shipgroups'. Skipping node.
But that is the name of each of the 3 groups that I'm editing... So I'm not sure where I'm going wrong here. Tried putting another / between groups and [@name, but that was invalid syntax apparently, tried putting " instead of ' around the defined name, but that messed with the sel= command... Kinda stumped on what needs to happen there o.O
[ external image ]
***modified***
"You can get more of what you want with kind words and a gun, than you can with just kind words" - Al Capone
SirNukes
Posts: 549
Joined: Sat, 31. Mar 07, 23:44
x4

Re: [ADVICE REQ] Syntax for removing parameters

Post by SirNukes »

There is a hidden node above root in egosoft's handling of xpath, so try starting with a '/', eg. '/groups/group[@name='sca_pirate']'.
argon_emperor
Posts: 1225
Joined: Mon, 12. Dec 05, 07:41
x4

Re: [ADVICE REQ] Syntax for removing parameters

Post by argon_emperor »

SirNukes wrote: Thu, 13. Dec 18, 00:19 There is a hidden node above root in egosoft's handling of xpath, so try starting with a '/', eg. '/groups/group[@name='sca_pirate']'.
You sir, are a genius. And I'm a goddamn idiot, because now that you've pointed it out, I've seen that so many other times and just didn't put two and two together XD No more errors now!

Now I just have to work out the right syntax for the remove command so I can get rid of the weight attribute in the ones that currently exist, as I want them all to have an even chance of spawning :S

But much thanks for that :)
[ external image ]
***modified***
"You can get more of what you want with kind words and a gun, than you can with just kind words" - Al Capone
argon_emperor
Posts: 1225
Joined: Mon, 12. Dec 05, 07:41
x4

Re: [ADVICE REQ] Syntax for removing parameters

Post by argon_emperor »

Okay, so we definitely have the extra ships spawning in now, so that's all good, and I think rather than all being an equal chance, I will give a bit of weighting... Namely in the mixed group and reduce the weight of the M's and increase the S's

So in the following code:

Code: Select all

  <group name="sca_pirate_sm">
    <select macro="ship_arg_m_bomber_02_a_macro" weight="1"/>
    <select macro="ship_arg_s_scout_01_a_macro" weight="36"/>
    <select macro="ship_arg_s_scout_01_b_macro" weight="36"/>
    <select macro="ship_tel_s_scout_01_a_macro" weight="54"/>
    <select macro="ship_tel_s_scout_01_b_macro" weight="54"/>
    <select macro="ship_tel_s_fighter_01_a_macro" weight="9"/>
    <select macro="ship_tel_s_fighter_01_b_macro" weight="9"/>
  </group>
That's the original for the mixed group, I want to alter the weights to be 5 for the M, 75 for the fighters, and 95 for the scouts, is this the replace lines I would use?

Code: Select all

<replace sel="/groups/group[@name='sca_pirate_sm']/select[@macro='ship_arg_m_bomber_02_a_macro']/@weight">5</>
	<replace sel="/groups/group[@name='sca_pirate_sm']/select[@macro='ship_arg_s_scout_01_a_macro']/@weight">95</>
	<replace sel="/groups/group[@name='sca_pirate_sm']/select[@macro='ship_arg_s_scout_01_b_macro']/@weight">95</>
	<replace sel="/groups/group[@name='sca_pirate_sm']/select[@macro='ship_tel_s_scout_01_a_macro']/@weight">95</>
	<replace sel="/groups/group[@name='sca_pirate_sm']/select[@macro='ship_tel_s_scout_01_b_macro']/@weight">95</>
	<replace sel="/groups/group[@name='sca_pirate_sm']/select[@macro='ship_tel_s_fighter_01_a_macro']/@weight">75</>
	<replace sel="/groups/group[@name='sca_pirate_sm']/select[@macro='ship_tel_s_fighter_01_b_macro']/@weight">75</>
Reading through the XML patch guide in the sticky, but it doesn't cover multi-attribute lines, so I'm not 100%, and it just looks wrong to me

EDIT: Nevermind, got it all working. But I was right, it was wrong. Debug kept throwing an error, googling around on error 76 eventually led me to find that rather than /> at the end of the replace line, it actually had to be /replace>... Even though I'm sure I've seen lines terminated as just /> before....
[ external image ]
***modified***
"You can get more of what you want with kind words and a gun, than you can with just kind words" - Al Capone

Return to “X4: Foundations - Scripts and Modding”