Difrificulties setting the price of Items/cargo for my mardket mod! disconnected

Started by ninekorn, December 24, 2017, 12:48:15 PM

ninekorn

discontinued 2023 july 29th . by ninekorn

ai_enabled

Hi,

The price is adjusted for every player as you think. It's not clear from the scripting as this code is called from C#.
Here are methods which we're calling:
Station.js - CalculateBuyPriceOfItemModifier and CalculateSellPriceOfItemModifier - for calculation of item price.
Station.js - CalculateBuyPriceOfCargo and CalculateSellPriceOfCargo - for calculation of cargo price.

Unfortunately, these methods require quite a complex argument structure. For items:

int base_id;
int faction_relation; // this is a pre-calculated relation between the player's ship and the station faction
int item_id;
int ship_id;


For cargo it's more complicated:


[code]
string base_faction; // station faction ID
int base_id; // station ID
string cargo_id; // XML ID of the cargo
double cargo_price; // base price of cargo (from XML, I'm very unsure if this can be get from scripting API now - we might need an update to the game server for this API)
int faction_relation; // relation between the player's ship and the station faction
string ship_faction; // player ship faction ID
int ship_id; // player ship
int status; // cargo status


Alas, it's really complicated. Maybe a better approach would be to implement new scripting API methods accepting ship ID, station ID and item ID or cargo XML ID and returning the calculated price (by reusing the C# code).

Regards!

ninekorn

discontinued 2023 july 29th . by ninekorn

ai_enabled

I verified the C# code and can definitely say that it calling Station.js file, methods CalculateBuyPriceOfCargo and CalculateSellPriceOfCargo, to calculate the prices. Have you tried to add the console logging to these two methods?
The game calculates the prices for a player during docking, when the items are added/removed from the shop items list (such as during stock items regeneration) and when a player tries to buy/sell to calculate the current price.

"args.cargo_price" is the price of cargo/resource from the XML file.
It seems there is no API for getting the price by cargo/resource XML ID so you're stuck with this for now, alas.

ninekorn

discontinued 2023 july 29th . by ninekorn

ai_enabled

You're right, the prices are modified (and their statuses too). The price for cargo is calculated by SetResourceBasePrice method at Station.js. This is implemented this way to adjust prices randomly with 10% deviation. Yeah, that's really overcomplicated. Each station generates items/cargo for sale and calls this method for each of them to calculate the price, then this price is stored on server, but players receive another price which is calculated by CalculateBuyPriceOfCargo and CalculateSellPriceOfCargo (or same methods for items).
The only solution will be to implement new API methods for getting the final price of item/cargo by providing player's ship ID and station ID.

ninekorn

discontinued 2023 july 29th . by ninekorn

ninekorn

discontinued 2023 july 29th . by ninekorn