# Talk:Buying/Selling/Transferring

## Transferring

Formulas:

Time = 6 + Globe_Distance(base1.x, base1.y, base2.x, base2.y) / 200

Globe_Distance calculated as sqrt(x*x + y*y + z*z) of 3d coordinate, so maximum from north pole to south isn't surface distance, but straight line through the Earth. Coordinate as far as I see is taken in sin/cos units, i.e. sphere radius is 1024. Thus, maximum distance will be 2048, and according formula it will take 6 + 2048/200 = 16.24 hours. --Volutar 22:24, 11 April 2011 (EDT)

Cost = Globe_Distance(base1.x, base1.y, base2.x, base2.y) / 20 * item_transfer_cost

where item_transfer_cost calculated for each transferred item ( * Quantity):

soldier = 5 craft = 25 scientists/engineers = 5 alien corpse = 20 all other general store items = 1

So one craft transfer cost from one pole to another will be 2048/20 * 25 = $2560

Grenade transfer cost will be 2048/20 * 1 = $102.4

Three grenades 2048/20 * 3 = $307.2

--Volutar 04:30, 12 April 2011 (EDT)

- Do you know what it is using for the Z coordinate? Is Z always == Earth's radius (1024 units)? This suggests that for long distances, there's a possible exploit of Transferring a Skyranger to a nearby base first, rather than flying all the way to the target on the Geoscape. See also: Talk:WORLD.DAT#Flat_Earth_Projection and UFO_Interception#Movement Spike 04:33, 12 April 2011 (EDT)

- Z is just a Z, from -1024 to +1024... Just a XYZ coordinate in space of point of sphere. So distances are like a concentric circles through the Earth. Items, being tranferred from USA to Asia, happen to go thorugh plant's core :)
- By the way, about "accumulation bug". There is the function calculating current transfer cost. It references to Purchase table (which is modified when editing transfer list). For crafts it references to "transfer" flag field of "location" table (field 0x0E). For soldiers it references to Soldier's field 0x04 (link to craft) - it checked against -2, which is unused value, so soldiers are transferred for free (they should be using field 0x29 field). The thing is, it calculates this cost for normal items only when they are "launched" but for crafts and soldiers - when they are "in the way".. So actually there are 2 bugs: 1) calculating craft transfer cost each time when it's in the way (wrong field #1); 2) calculating soldiers transfer cost each time when they have craft_idx==-2 (really wrong field... they really missed something). --Volutar 05:30, 12 April 2011 (EDT)