Howdy,
Anyone have this coded already? or point me to some reference?
of course time = distance/speed
time being ticks, distance being 664.(216) per unit of distance 10 for example, speed let's say 20mph 1950's ferry boat being 32 kph-ish...
6642.(163) / 32 * 2048(it a boat) = .1 or so ticks 74 ticks in a day 7.4 days for a ferry to go 10 squares...
hover craft is faster 112 kph-ish...
6642.(163) / 112 * 2048(it a boat) = .03 ish ticks 74 ticks in a day 2.2 days for a hovercraft to go 10 squares...
Am I in the ball park?
Please advise,
game days to travel distance x at speed y?
Moderator: OpenTTD Developers
game days to travel distance x at speed y?
I DO like a nice caboose...
Re: game days to travel distance x at speed y?
In SuperLib I have a function Engine.GetFullSpeedTravelTime. You might want to take a look at this and subtract full speed with your desired speed:
Full source code
Full source code
Code: Select all
function _SuperLib_Engine::GetFullSpeedTraveltime(engine, distance)
{
// X km/h => X/27 tiles/day
/* Multiply by this from start and then remove it at the end in order to
* not lose to much significance in the calculation process.
*
* On 100 km/h the tile/day speed becomes 3.7, which would become just
* 3 in the integer conversion which would be loosing to much detail.
*/
local MULTI = 50;
local km_h_speed = AIEngine.GetMaxSpeed(engine) * MULTI;
local tile_speed = km_h_speed / 27;
local travel_time_days = distance * MULTI / tile_speed;
return travel_time_days;
}
My OpenTTD contributions (AIs, Game Scripts, patches, OpenTTD Auto Updater, and some sprites)
Junctioneer (a traffic intersection simulator)
Junctioneer (a traffic intersection simulator)
Re: game days to travel distance x at speed y?
Alternatively you could create your own helper function by removing the variable named MULTI and moving divisor 27 to act as multiplier, thus improving quality, accuracy and optimizing the function performance. If possible, one should always prefer multiplying over dividing. This way there is no need for additional multiplier to preserve the accuracy. This is the result:
Or simply:
Code: Select all
function GetFullSpeedTravelTime(engine, distance)
{
// X km/h => X/27 tiles/day
local travel_time_days = 27 * distance / AIEngine.GetMaxSpeed(engine);
return travel_time_days;
}
Code: Select all
local travel_time_days = 27 * distance / AIEngine.GetMaxSpeed(engine);
Who is online
Users browsing this forum: No registered users and 5 guests