Page 1 of 1

Can a dev please explain how turret loadout for NPC ships works

Posted: Tue, 14. Jan 20, 13:09
by Max Bain
I have a question about weapon/turret loadouts for NPC ships that is described in this thread:

viewtopic.php?f=181&t=417470&sid=a1e7e7 ... 81709a705d

TLDR:
How exactly are turret loadouts calculated and what exact role has the turret threashold for the loadout?
How can I achieve that a single ships uses more vaiation of different turrets without giving them nearly equal prices. So far it seems that ships try to use only the most expensive turrets what is problematic if you want to have some turrets that are just stronger but also more expensive than others.
I want that this weapon is mounted for 1 maybe 2 groups per ship maybe at max and more common should be the cheaper weapons.


I know this belongs to the modding forum, but no modder does know the exact algorithm for turret layouts so I hope a dev can give me (and other modders) a detailed description.

Re: Can a dev please explain how turret loadout for NPC ships works

Posted: Tue, 14. Jan 20, 14:07
by CBJ
Two values control fittings chosen for a loadout, the level and the variation. The level is compared with the thresholds for each individual item to determine if it can be used, and then the "best" (read "most expensive") items available are chosen from what is left. To avoid everything having the same loadout, the variation is used to determine the chance of the selection dropping through to the next most expensive item, and it is used repeatedly so that the third or fourth may occasionally be chosen too. A higher variation means a greater chance of dropping through.

So, to achieve what you want, you need to give your one or two ships per group a higher level (and set some weapon thresholds accordingly) and then give the other ships a lower level. You may also want to tweak the variation a bit to give more or less variety in fittings within each set of ships.

Re: Can a dev please explain how turret loadout for NPC ships works

Posted: Tue, 14. Jan 20, 14:32
by Max Bain
CBJ wrote:
Tue, 14. Jan 20, 14:07
Two values control fittings chosen for a loadout, the level and the variation. The level is compared with the thresholds for each individual item to determine if it can be used, and then the "best" (read "most expensive") items available are chosen from what is left. To avoid everything having the same loadout, the variation is used to determine the chance of the selection dropping through to the next most expensive item, and it is used repeatedly so that the third or fourth may occasionally be chosen too. ".

So, to achieve what you want, you need to give your one or two ships per group a higher level (and set some weapon thresholds accordingly) and then give the other ships a lower level. You may also want to tweak the variation a bit to give more or less variety in fittings within each set of ships.
Thank you very much!

Just one more question:
Where is that property "level" you are talking about? I know of a property "variation" in the jobs file, but not in the ship file. I thought that this would spawn a random number of ships of that job. Where do I have to look for that property? Is it

Code: Select all

<secrecy level="1" />
in the ship file?

Edit: Is cost the only value that defines the hirarchy if the weapons are above the needed threshold? Or does a weapon with a high threshold maybe has a bonus/malus on the cost for the chance it will be taken?

Edit2:
I think you mean this in the parameters.xml:

Code: Select all

  <loadout level="0.5" variation="0.3" ammo="0.9" software="0.9">
    <units min="0.2" max="1.0">
      <defence min="0.2" max="0.8" />
    </units>
    <group threshold="0.75" />
  </loadout>
Can I add this to each single job in the jobs file?
Level means that all ships use weapons with threshold >= 0.5. And variation 0.3 means? That 30% below the most expensive weapon will be used also?

Re: Can a dev please explain how turret loadout for NPC ships works

Posted: Tue, 14. Jan 20, 15:31
by j.harshaw
Loadout level and variation can be defined for each job entry:

Code: Select all

<job id="antigone_destroyer_patrol_l_border_sector" name="{20204,3301}" comment="each border sector">
  ...
  <ship>
    <select faction="antigone" tags="[military, destroyer]" size="ship_l"/>
    <loadout>
      <level exact="1.0"/>
      <variation exact="0"/>
    </loadout>
    <owner exact="antigone" overridenpc="true"/>
  </ship>
  ...
</job>

Re: Can a dev please explain how turret loadout for NPC ships works

Posted: Tue, 14. Jan 20, 15:53
by Max Bain
j.harshaw wrote:
Tue, 14. Jan 20, 15:31
Loadout level and variation can be defined for each job entry:

Code: Select all

<job id="antigone_destroyer_patrol_l_border_sector" name="{20204,3301}" comment="each border sector">
  ...
  <ship>
    <select faction="antigone" tags="[military, destroyer]" size="ship_l"/>
    <loadout>
      <level exact="1.0"/>
      <variation exact="0"/>
    </loadout>
    <owner exact="antigone" overridenpc="true"/>
  </ship>
  ...
</job>
Thanks!

How does variation work? I have looked into all jobs and I only find <variation exact="0"/>. Does that mean that each turret has the same weapon? When I write

Code: Select all

<variation exact="1"/>
will this result in the ship fitting 2 different types of weapons? I guess its then the two most expensive ones.. Can I write min max like for levels?
Or how does it work? Is it even an integer value like for quota?

Re: Can a dev please explain how turret loadout for NPC ships works

Posted: Tue, 14. Jan 20, 19:30
by Max Bain
I dont get it.

I tried something like this:

Code: Select all

			
			<loadout>
				<level min="0.6" max="1.0" />
				<variation exact="0.3"/>
			</loadout>
But then a lot of the turret slots are empty. Why that? I need to understand the math behind it.
Even when the minimum level of 0.6 will be rolled and a variation of 0.3 will be substracted, then it still is 0.3 and there are plenty of turrets with that threshold. If the 0.3 is percentual value of the level then it would be even higher.

Can someone please explain this to me?

Edit:
Even when I set variation to 0 some slots are empty :gruebel:
Maybe I need to say that all groups have at least one turret, but not all slots are used, only 3 of 5 or so.


Edit:
When I want that lower tier weapons (lower threshold) will be used I have to lower the min level, but that will automatically reduce the used slots what is bad. I want most combat ship use standard turrets but for all of their slots. How can I do that?