Possible to modify individual prices for ship mods?

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

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

Daemonjax
Posts: 282
Joined: Tue, 27. May 14, 01:54
x4

Possible to modify individual prices for ship mods?

Post by Daemonjax »

For example, let's say I want to increase the price of the Nudger engine mod from 50k to 250k?

I tried changing the min/average/max lines, but they seem to have no effect.

Code: Select all

	<replace sel="/wares/ware[@id='mod_engine_forwardthrust_02_mk1']/price">
		<price min="212500" average="250000" max="287500" />
	</replace>
or...

Code: Select all

	<replace sel="/wares/ware[@id='mod_engine_forwardthrust_02_mk1']/price/@min">212500</replace>
	<replace sel="/wares/ware[@id='mod_engine_forwardthrust_02_mk1']/price/@average">250000</replace>
	<replace sel="/wares/ware[@id='mod_engine_forwardthrust_02_mk1']/price/@max">287500</replace>

So... Is it hardcoded, or am I doing it in the wrong place?

I just assumed it would use the average price, but maybe it just uses 50k for all mk1 ship mods.

I grepped all the exacted files for:
mod_engine_forwardthrust_02_mk1
... and it only comes up in wares.xml and equipmentmods.xml

I guess it's really an "installation fee" not a "price"... oh well.
vvvvvvvv
Posts: 1069
Joined: Tue, 28. Nov 23, 15:38
x4

Re: Possible to modify individual prices for ship mods?

Post by vvvvvvvv »

Daemonjax wrote: Sat, 26. Apr 25, 06:27 For example, let's say I want to increase the price of the Nudger engine mod from 50k to 250k?
I would try to find a script that controls the button on modding screen. Because wares define their value as items, but you do not carry mods as items.

See... 08.cat/ui/addons/ego_detailmonitor/menu_ship_configuration.lua

function menu.buttonInstallMod, line 1317. Then start untangling the logic from there.
Daemonjax
Posts: 282
Joined: Tue, 27. May 14, 01:54
x4

Re: Possible to modify individual prices for ship mods?

Post by Daemonjax »

vvvvvvvv wrote: Sat, 26. Apr 25, 12:31 I would try to find a script that controls the button on modding screen. Because wares define their value as items, but you do not carry mods as items.

See... 08.cat/ui/addons/ego_detailmonitor/menu_ship_configuration.lua

function menu.buttonInstallMod, line 1317. Then start untangling the logic from there.
Cool, thanks!

I think that led me to the right place:

menu_ship_configuration.lua -> function menu.displayModBlueprint(...):
line# 6976:

Code: Select all

row[5]:setColSpan(4):createButton({ active = active, mouseOverText = mouseovertext }):setText(text, { halign = "center" })
		if (type == "ship") or (type == "engine") then
			row[5].handlers.onClick = function () return menu.buttonInstallMod(type, menu.object, moddata.ware, Helper.modQualities[moddata.quality].price, nil, nil, dismantle) end
		elseif (type == "turret") and isgroup then
			row[5].handlers.onClick = function () return menu.buttonInstallMod(type, menu.object, moddata.ware, Helper.modQualities[moddata.quality].price, slotdata.context, slotdata.group, dismantle) end
		elseif type == "shield" then
			row[5].handlers.onClick = function () return menu.buttonInstallMod(type, menu.object, moddata.ware, Helper.modQualities[moddata.quality].price, slotdata.context, slotdata.group, dismantle) end
		else
			row[5].handlers.onClick = function () return menu.buttonInstallMod(type, slotdata.component, moddata.ware, Helper.modQualities[moddata.quality].price, nil, nil, dismantle) end
		end
That codeblock looks like it creates the actual button, and it gets the price from this array (using the mod's quality as the index):
Helper.modQualities[moddata.quality].price

... so the price of every mod is simply determined by its quality level, not it's name or anything.

Changing how all that logic works is doable, but it's more complicated than I'd like it to be because it's an array lookup and not function call (so I could put all the needed changes in that one function call). Oh well. If I wanted to go forward with my idea (note to self mostly), I'd need to start with replacing each array lookup for mod price with a function call.

Return to “X4: Foundations - Scripts and Modding”