how to determine refit cost?
Moderator: OpenTTD Developers
how to determine refit cost?
Howdy,
I am trying to build a plane and refit it for mail but sometimes I only have enough money for the plane and not the refit and then I have the wrong plane flying around.
I tried test mode + accounting but i get precondition fail error on the refit.
Please advise,
Kev!
I am trying to build a plane and refit it for mail but sometimes I only have enough money for the plane and not the refit and then I have the wrong plane flying around.
I tried test mode + accounting but i get precondition fail error on the refit.
Please advise,
Kev!
I DO like a nice caboose...
Re: how to determine refit cost?
As far as I know, this is a design problem with the NewGRF spec, that the cost to refit an engine may not be the same as refitting the actual built vehicle. Some may call it a feature rather than a design problem, however it produces problems like the one you have experienced.
Without seeing your code, I can't say if you made any error on your side regarding doing the cost estimation. (regardless of the issue stated above)
What I think you should do is to sell the aircraft again if the refit fails. This might need some back-off mechanism in order to the AI not get into a repetitive behavior. This repetitive behavior could cost a few money units each time (loss of vehicle value between the tick when they are bought and when they are sold 2 ticks later).
Without seeing your code, I can't say if you made any error on your side regarding doing the cost estimation. (regardless of the issue stated above)
What I think you should do is to sell the aircraft again if the refit fails. This might need some back-off mechanism in order to the AI not get into a repetitive behavior. This repetitive behavior could cost a few money units each time (loss of vehicle value between the tick when they are bought and when they are sold 2 ticks later).
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: how to determine refit cost?
While many grf authors wish that refit cost was subject to advanced fiddling-with via callback, this is not actually currently the case.Zuu wrote:As far as I know, this is a design problem with the NewGRF spec, that the cost to refit an engine may not be the same as refitting the actual built vehicle.
Re: how to determine refit cost?
Kev:
It would have been easier if you had posted some code. So, I can only guess what you tried.
It sounds as if you entered testmode, then build a vehicle in test mode and tried to refit that one.
That won't work. The vehicle is not actually built in test mode, so you cannot refit it.
The only solution is, as Zuu said, to build the vehicle, try to refit it, and if that fails, sell the vehicle again.
Btw. the same happens to humans. Coincidently just yesterday I started a game with an train set I never played before, built a first route and had barely enough money to purchase the train. Then I discovered that refitting the wagons cost 5 times more than purchasing them. So I was bankrupt
It would have been easier if you had posted some code. So, I can only guess what you tried.
It sounds as if you entered testmode, then build a vehicle in test mode and tried to refit that one.
That won't work. The vehicle is not actually built in test mode, so you cannot refit it.
The only solution is, as Zuu said, to build the vehicle, try to refit it, and if that fails, sell the vehicle again.
Btw. the same happens to humans. Coincidently just yesterday I started a game with an train set I never played before, built a first route and had barely enough money to purchase the train. Then I discovered that refitting the wagons cost 5 times more than purchasing them. So I was bankrupt
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Re: how to determine refit cost?
Howdy,
Frosch is correct. That is exactly what I was trying to do. Thank you.
Wow, is an AIEngine.GetRefitCost(engine_id) too much to ask? I suppose I could, each time I build a plane, enter testmode and accounting mode, try to refit, get the cost and remember it in case I need it later? Dang, that's not too much trouble!
Kev!
Frosch is correct. That is exactly what I was trying to do. Thank you.
Wow, is an AIEngine.GetRefitCost(engine_id) too much to ask? I suppose I could, each time I build a plane, enter testmode and accounting mode, try to refit, get the cost and remember it in case I need it later? Dang, that's not too much trouble!
Kev!
I DO like a nice caboose...
- planetmaker
- OpenTTD Developer
- Posts: 9432
- Joined: 07 Nov 2007 22:44
- Location: Sol d
Re: how to determine refit cost?
It is.Kev! wrote: Wow, is an AIEngine.GetRefitCost(engine_id) too much to ask?
It could depend on date, day of month, year, player number, cargo type, track type, all at once, subject to change on a daily basis. NewGRFs can do what they want in that arena, no way to reliably predict it.
OpenTTD: manual | online content | translations | Wanted contributions and patches
#openttdcoop: blog | wiki | public server | DevZone | NewGRF web translator
DevZone - home of the free NewGRFs: OpenSFX | OpenMSX | OpenGFX | Swedish Rails | OpenGFX+ Trains|RV|Industries|Airports|Landscape | NML
Re: how to determine refit cost?
Well, as Pikka said. The cost is actually known.
However, the capacity is unknown, which is usually the next thing which is asked for
At some point OTTD will likely learn to do these test-purchases itself. It is also needed for other non-AI stuff, like purchase+refit for human players, templated autoreplace, and more... but not now
However, the capacity is unknown, which is usually the next thing which is asked for
At some point OTTD will likely learn to do these test-purchases itself. It is also needed for other non-AI stuff, like purchase+refit for human players, templated autoreplace, and more... but not now
⢇⡸⢸⠢⡇⡇⢎⡁⢎⡱⢸⡱⢸⣭⠀⢸⢜⢸⢸⣀⢸⣀⢸⣭⢸⡱⠀⢰⠭⡆⣫⠰⣉⢸⢸⠀⢰⠭⡆⡯⡆⢹⠁⠀⢐⠰⡁
Who is online
Users browsing this forum: No registered users and 40 guests