Community Forum

Changing lease cost on equipment

Forum Overview >> Scripting

CategoryScripting
Created24.03.2019 17:53


Kaj-aage Henneberg (kahfs) 24.03.2019 17:53
Hello,

I'm putting the finishing touch on my first mod, which redefines a number of game parameters toward real-life values. As a last thing to do I wanted to reduce the cost of leasing equipment, but I'm not successful.
My first approach was to redefine a parameter in storeManager by running these lines within and update(dt) method.

if g_storeManager.items ~= nil then
for k,items in pairs(g_storeManager.items) do
items.runningLeasingFactor = RN.DEFAULT_RUNNING_LEASING_FACTOR;
end;
end;

While this will change the runningLeasingFactor of each store item according to a DebugUtil.printTableRecursively(g_storeManager,"_",0,4);
nothing has changed in the store menu.

Looking into the LuaDOC 1.3 StoreManager:LoadItem (line 412)

storeItem.runningLeasingFactor = Utils.getNoNil(getXMLFloat(xmlFile, storeDataXMLName..".runningLeasingFactor"), EconomyManager.DEFAULT_RUNNING_LEASING_FACTOR)

I then tried to redefine some parameters in EconomyManager.vInspired by the info put up by Espen Killi:

EconomyManager = {}

EconomyManager.DEFAULT_RUNNING_LEASING_FACTOR = 0.050000
EconomyManager.CONFIG_CHANGE_PRICE = 1000.000000
EconomyManager.MAX_GREAT_DEMANDS = 3.000000
EconomyManager.DIRECT_SELL_MULTIPLIER = 1.200000
EconomyManager.PRICE_MULTIPLIER = {
1 = 3.000000,
2 = 1.800000,
3 = 1.000000
}
EconomyManager.LIFETIME_OPERATINGTIME_RATIO = 0.083330
EconomyManager.COST_MULTIPLIER = {
1 = 0.400000,
2 = 0.700000,
3 = 1.000000
}
EconomyManager.sendNumBits = 2.000000
EconomyManager.MAX_DAILYUPKEEP_MULTIPLIER = 4.000000
EconomyManager.PER_DAY_LEASING_FACTOR = 0.010000
EconomyManager.DEFAULT_LEASING_DEPOSIT_FACTOR = 0.020000
EconomyManager.PRICE_DROP_MIN_PERCENT = 0.600000

I was confirmed that these were exactly the parameters I wanted to change. So below the first 4 already working lines of code I entered three lines more:

local gameLevel = g_currentMission.missionInfo.economicDifficulty;
g_currentMission.economyManager.PRICE_MULTIPLIER[gameLevel] = RN.gameLevel.sellPriceMultiplier[gameLevel];
g_currentMission.economyManager.COST_MULTIPLIER[gameLevel] = RN.gameLevel.buyPriceMultiplier[gameLevel];
g_currentMission.economyManager.DIRECT_SELL_MULTIPLIER = RN.DIRECT_SELL_MULTIPLIER;

g_currentMission.economyManager.DEFAULT_RUNNING_LEASING_FACTOR = RN.DEFAULT_RUNNING_LEASING_FACTOR;
g_currentMission.economyManager.PER_DAY_LEASING_FACTOR = RN.PER_DAY_LEASING_FACTOR;
g_currentMission.economyManager.DEFAULT_LEASING_DEPOSIT_FACTOR = RN.DEFAULT_LEASING_DEPOSIT_FACTOR;

Still, nothing changes in the store menu.

I've learned before from helpful wizards in this forum, that timing of assignments is important. economyManager cannot be indexed at the time when this mod is loading, so I have placed the assignments in an update(dt) method assuming that the assignment would then be executed after the game finished loading and the data structure is established.

I'm wondering, if there is another manager in play that I don't now about.

Bilbo Beutlin (BBeutlin) 24.03.2019 19:51
I'd guess the 'g_storeManager' or maybe the 'g_currentMission.shopController'.
Unluckily nothing of the economy is documented. I think this belongs to the 'secrets' which Giants will never reveal completely. ;)

And yes - in the economy the point in time for changes is important. Usually it's too late when the map has been loaded and the 'managers' have been setup. They seem to build up and use their own tables. Much work to scan them all. *g*

I would begin another way: I'd hook into the 'g_currentMission:addMoney()' function and adjust the price depending on kind of 'MoneyType.XYZ'.

Espen K. (estyx) 25.03.2019 16:44
Yeah as Bilbo mentions you probably have to do some more probing into the shopController and GUI.
And for what it's worth I think Giants really did a bad decision on both lack of documentation and encrypting script files.. Do they really expect modders to do all the work for them?? For time being I have disbanded the idea of creating mods for FS19, if there is any demand for it I will maybe update some docs for patch 1.3 to help others.
Best of luck on your project :)

Kaj-aage Henneberg (kahfs) 25.03.2019 20:49
Thank you Bilbo and Espen for commenting on my problem. I tried many things along the lines you have suggested. But, with my only recently started modding adventure I have to conclude, that I'm not the one to uncover the secrets of Farming Simulator. So for now, my mod will have to do without real-life leasing prices. What you can't solve with modding you have to solve with make-believe. Borrowing that 500.000 € potato harvester from your good friend and neighbor is better than leasing at 10500 € per hour ;-)

Jack Soor (jaksoor) 15.04.2019 19:50
Try with these lines, worked for me : (great mod by the way)

if g_storeManager.items ~= nil then
for k,items in pairs(g_storeManager.items) do
if items.allowLeasing then
items.runningLeasingFactor = RN.DEFAULT_RUNNING_LEASING_FACTOR;
end;
end;
end;

EconomyManager.DEFAULT_RUNNING_LEASING_FACTOR = RN.DEFAULT_RUNNING_LEASING_FACTOR;
EconomyManager.PER_DAY_LEASING_FACTOR = RN.PER_DAY_LEASING_FACTOR;
EconomyManager.DEFAULT_LEASING_DEPOSIT_FACTOR = RN.DEFAULT_LEASING_DEPOSIT_FACTOR;

Kaj-aage Henneberg (kahfs) 16.04.2019 20:02
Hi Jack.

Tried your fix and it works for me as well :-)

So cool. Thank you so much for taking the time to help out with this.
It was one of the last economic parameters left to change, and one that will help a lot when in need of less used equipment. I think this will make leasing a lot more popular.

Happy happy days....

Axel Fresh (Unknown) 03.08.2020 00:20
Hey kahfs,
is your Script availiable for download somewhere?

i want to put it on my Multiplayer server, so that the Leasingcost are to high for everyone,
that no one could lease anything in the beginning to get to much to big


Note: Log in to post. Create a new account here.