Page 1 of 1

Modding help! What controls NPC weapon loadouts?

Posted: Sat, 15. Jun 19, 06:58
by heyjustarooni
Hey guys, I've been working on a weapons mod, and I'm having trouble figuring out how to influence which weapons the NPCs equip. I've noticed a ware element <use threshold=x> but I'm not exactly sure how it works. My main concern is that I've seen a few NPC ships with no weapons equipped after I removed some vanilla weapons. I'm not sure if it's just ships that are spawned from new games or what. Any way to control the loadout of NPC ships? Thanks in advance!

Re: Modding help! What controls NPC weapon loadouts?

Posted: Sat, 15. Jun 19, 12:05
by Shuulo
heyjustarooni wrote:
Sat, 15. Jun 19, 06:58
Hey guys, I've been working on a weapons mod, and I'm having trouble figuring out how to influence which weapons the NPCs equip. I've noticed a ware element <use threshold=x> but I'm not exactly sure how it works. My main concern is that I've seen a few NPC ships with no weapons equipped after I removed some vanilla weapons. I'm not sure if it's just ships that are spawned from new games or what. Any way to control the loadout of NPC ships? Thanks in advance!
"Use threshold" says if a weapon can be used at all. If your ship has "level" in jobs as 0.5, but weapon has threshold of 0.6 it will not be used at all.
If threshold is OK than weapons ware price is the factor that determines what weapon will be equipped. The bigger the difference in price the more chance that weapon will not be used.
e.g. In Vanilla L Pulse laser is cheap, that's why you will very rarely see it on ships, I had to increase its price twice to force NPCs equip it more after I did full re-balance in my VRO mod.
You can download it from github and check how I did it.

BTW, what weapon mod are you making?

Re: Modding help! What controls NPC weapon loadouts?

Posted: Sun, 16. Jun 19, 01:30
by heyjustarooni
Thanks for the great response. It really helped to understand what's going on!

Also, you're the author of VRO? Your mod is what inspired me to work on one. I'm trying to take it back to the feel of the original X games, or at least X3 era. I'm hoping to publish it within the next month or 2. Love your mod, spent several hours with it! Some of the effects are truly amazing and far beyond what I'm capable of doing lol

Re: Modding help! What controls NPC weapon loadouts?

Posted: Sun, 16. Jun 19, 11:55
by Shuulo
heyjustarooni wrote:
Sun, 16. Jun 19, 01:30
Thanks for the great response. It really helped to understand what's going on!

Also, you're the author of VRO? Your mod is what inspired me to work on one. I'm trying to take it back to the feel of the original X games, or at least X3 era. I'm hoping to publish it within the next month or 2. Love your mod, spent several hours with it! Some of the effects are truly amazing and far beyond what I'm capable of doing lol
Yeah, if you have any questions or suggestions, you can PM me. Will be happy to see what you come up with in your mod :)
If you have any feedback for VRO it will be appreciated as well :)

Re: Modding help! What controls NPC weapon loadouts?

Posted: Tue, 14. Jan 20, 09:45
by Max Bain
Hi, can someone explain the threashold a bit more please (if theres is more)?

Is there a way to let the prices the same, but make weapons more or less used by NPCs? For example, when I increase the threshold from 0.8 to 0.95 will this result in ships using this weapon less often?
Will the threshold level for a ship be equal for all of its turrets or has each turret its own threshold level?

Is it maybe like this:
Each combat ship gets a random threshold level of above 0.8 means that each of its turret has a threshold level of 0.8-1.0. Each one has a different one resulting in each turret tries to fit the most expensive weapon with a higher threshold than its threshold level.

Or like this:
Each combat ship gets a random threshold level of above 0.8 means that each turret has the same threshold (above 0.8) resulting in all turrets fit the same most expensive weapon available for their threshold level.

Or is it something completely different?

I want to mix turrets more for the Ai, but doing this only over the price sounds somehow very bad.

Re: Modding help! What controls NPC weapon loadouts?

Posted: Tue, 14. Jan 20, 11:00
by Shuulo
Max Bain wrote:
Tue, 14. Jan 20, 09:45
Hi, can someone explain the threashold a bit more please (if theres is more)?

Is there a way to let the prices the same, but make weapons more or less used by NPCs? For example, when I increase the threshold from 0.8 to 0.95 will this result in ships using this weapon less often?
Will the threshold level for a ship be equal for all of its turrets or has each turret its own threshold level?

Is it maybe like this:
Each combat ship gets a random threshold level of above 0.8 means that each of its turret has a threshold level of 0.8-1.0. Each one has a different one resulting in each turret tries to fit the most expensive weapon with a higher threshold than its threshold level.

Or like this:
Each combat ship gets a random threshold level of above 0.8 means that each turret has the same threshold (above 0.8) resulting in all turrets fit the same most expensive weapon available for their threshold level.

Or is it something completely different?

I want to mix turrets more for the Ai, but doing this only over the price sounds somehow very bad.
Threshold is set in Jobs file and works like in second scenario you described. If a ship will have threshold = 1 then it will try to select the most expensive weapon there is in the game, as threshold 1 is the maximum.
If threshold of the ship is 0.5 it will try to select the most expensive weapons with threshold 0 - 0.5.

Also note that not always the most expensive guns are selected, there is a variation, but the more the difference in price the less it will select the gun. If you make plasma like 2 times more expensive than the gun before it it will be selected in most cases. That's why in VRO prices difference is not so drastic

Re: Modding help! What controls NPC weapon loadouts?

Posted: Tue, 14. Jan 20, 11:33
by Max Bain
Is it maybe possible to change the variation? It must be some kind of value, the question is, is it available for modders or only developers...

Re: Modding help! What controls NPC weapon loadouts?

Posted: Tue, 14. Jan 20, 12:20
by Shuulo
Max Bain wrote:
Tue, 14. Jan 20, 11:33
Is it maybe possible to change the variation? It must be some kind of value, the question is, is it available for modders or only developers...
That is what I was thinking, and i didnt find anything like that and I looked in almost every game file, it seems to be a hardcoded thing.
The other thing are the turret groups as weapons are assigned to them separately, so having a lot of variation will make ships fit different turrets on each turret group, which may look a bit strange, so i try to limit this with thresholds.

Re: Modding help! What controls NPC weapon loadouts?

Posted: Tue, 14. Jan 20, 15:15
by Max Bain
Shuulo wrote:
Tue, 14. Jan 20, 12:20
Max Bain wrote:
Tue, 14. Jan 20, 11:33
Is it maybe possible to change the variation? It must be some kind of value, the question is, is it available for modders or only developers...
That is what I was thinking, and i didnt find anything like that and I looked in almost every game file, it seems to be a hardcoded thing.
The other thing are the turret groups as weapons are assigned to them separately, so having a lot of variation will make ships fit different turrets on each turret group, which may look a bit strange, so i try to limit this with thresholds.
Look here:
viewtopic.php?f=181&t=421483

It explains a bit more how to solve that problem. I think one way would be over a big amount of different jobs where you create a job for a ship with a low (max) threshold and one with a high (min). Then you can also increase the variation. For the weapons it might help that weapons that cost a lot have a very high threshold and that weapons of similar threshold have roughtly the same costs. Then you can put weapons that are very expensive within a threshold group and give just a few jobs this threshold. The others will take weapons of lower threshold where the costs should be similar as well.
Maybe that helps even if it seems to be a lot of work.

Re: Modding help! What controls NPC weapon loadouts?

Posted: Tue, 14. Jan 20, 16:00
by Shuulo
Max Bain wrote:
Tue, 14. Jan 20, 15:15
Shuulo wrote:
Tue, 14. Jan 20, 12:20
Max Bain wrote:
Tue, 14. Jan 20, 11:33
Is it maybe possible to change the variation? It must be some kind of value, the question is, is it available for modders or only developers...
That is what I was thinking, and i didnt find anything like that and I looked in almost every game file, it seems to be a hardcoded thing.
The other thing are the turret groups as weapons are assigned to them separately, so having a lot of variation will make ships fit different turrets on each turret group, which may look a bit strange, so i try to limit this with thresholds.
Look here:
viewtopic.php?f=181&t=421483

It explains a bit more how to solve that problem. I think one way would be over a big amount of different jobs where you create a job for a ship with a low (max) threshold and one with a high (min). Then you can also increase the variation. For the weapons it might help that weapons that cost a lot have a very high threshold and that weapons of similar threshold have roughtly the same costs. Then you can put weapons that are very expensive within a threshold group and give just a few jobs this threshold. The others will take weapons of lower threshold where the costs should be similar as well.
Maybe that helps even if it seems to be a lot of work.
And this is funny, as I already use variation for some jobs :) though i thought it works a l like that: if variation is 0.1, so threshold 0.5 will be really 0.4-0.6. If variation is really to drop the most expansive thing that its good, will change some of jobs as well.

Re: Modding help! What controls NPC weapon loadouts?

Posted: Tue, 14. Jan 20, 16:12
by Max Bain
Shuulo wrote:
Tue, 14. Jan 20, 16:00
Max Bain wrote:
Tue, 14. Jan 20, 15:15
Shuulo wrote:
Tue, 14. Jan 20, 12:20


That is what I was thinking, and i didnt find anything like that and I looked in almost every game file, it seems to be a hardcoded thing.
The other thing are the turret groups as weapons are assigned to them separately, so having a lot of variation will make ships fit different turrets on each turret group, which may look a bit strange, so i try to limit this with thresholds.
Look here:
viewtopic.php?f=181&t=421483

It explains a bit more how to solve that problem. I think one way would be over a big amount of different jobs where you create a job for a ship with a low (max) threshold and one with a high (min). Then you can also increase the variation. For the weapons it might help that weapons that cost a lot have a very high threshold and that weapons of similar threshold have roughtly the same costs. Then you can put weapons that are very expensive within a threshold group and give just a few jobs this threshold. The others will take weapons of lower threshold where the costs should be similar as well.
Maybe that helps even if it seems to be a lot of work.
And this is funny, as I already use variation for some jobs :) though i thought it works a l like that: if variation is 0.1, so threshold 0.5 will be really 0.4-0.6. If variation is really to drop the most expansive thing that its good, will change some of jobs as well.
What you wanted to achieve is <level min="0.4" max="0.6"/> or something like that.

Re: Modding help! What controls NPC weapon loadouts?

Posted: Tue, 14. Jan 20, 17:05
by Shuulo
Max Bain wrote:
Tue, 14. Jan 20, 16:12
Shuulo wrote:
Tue, 14. Jan 20, 16:00
Max Bain wrote:
Tue, 14. Jan 20, 15:15


Look here:
viewtopic.php?f=181&t=421483

It explains a bit more how to solve that problem. I think one way would be over a big amount of different jobs where you create a job for a ship with a low (max) threshold and one with a high (min). Then you can also increase the variation. For the weapons it might help that weapons that cost a lot have a very high threshold and that weapons of similar threshold have roughtly the same costs. Then you can put weapons that are very expensive within a threshold group and give just a few jobs this threshold. The others will take weapons of lower threshold where the costs should be similar as well.
Maybe that helps even if it seems to be a lot of work.
And this is funny, as I already use variation for some jobs :) though i thought it works a l like that: if variation is 0.1, so threshold 0.5 will be really 0.4-0.6. If variation is really to drop the most expansive thing that its good, will change some of jobs as well.
What you wanted to achieve is <level min="0.4" max="0.6"/> or something like that.
Its still possible that it works the same way actually, so will need a bit of tests with variation i believe, will have some time tomorrow to go through it.