Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

df.world-data.xml:world_river elements unk_8c and unk_9c are probably flow and exit tile #201

Closed
PatrikLundell opened this issue Jun 22, 2017 · 1 comment

Comments

@PatrikLundell
Copy link
Contributor

PatrikLundell commented Jun 22, 2017

As far as I could see an unk_8c value of 0 corresponds to the pre embark region to calling the river a 'brook', while it changes to 'stream' for larger values. It also seems the values are increasing the further down the course you get. As a speculation, that value ought to correspond to the width, but I haven't investigated that. Edit: Hacking the values and then moving to the region to embark did NOT change the 'brook' designation, nor did an embark show any changed brook width.

unk_9c seems to match the region exit tile of the river. The edge on which tile this exit occurs is given by the side on which the world coordinates for the next segment is located. Edit: Hacking those values did change where exits appeared as expected.

Edit 2: A new attempt with unk_8c showed it is related to width, but I had used to small values previously. Width (2 m tiles); "flow"
4: <= 3478
5: 3579
6: 4348
7: 5218
8: 6087
9: 6957
10: 7827
11: 8696
12: 9566
13: 10435
14: 11305
15: 12174
16: 13044
17: 13914
18: 14783
19: 15653
20: 16522
21: 17392
22: 18261
23: 19131
24: 20000
25: 20870
26: 21740
27: 22609
28: 23479
29: 24348
30: 25218
31: 26087
32: 26957
33: 27827
34: 28696
35: 29566
36: 30435
37: 31305
38: 32174
39: 33044
40: 33914
41: 34783
42: 35653
43: 36522
44: 37392
45: 38261
46: 39131
47: 40000

The formula seems to be: width = (flow / 40000 * 46) + 1, with a minimum width of 4.

In addition to the above, I've found the following relations (I haven't tested with a brook):
< 5000 => Stream
5000 - 9999 => Minor River
10000 - 19999 => River
20000 -> => Major River. It seems the maximum river width is 47, although the flow can be higher than 40000.

Edit3:
Rather than tedious manual river width determination, I've made a script to measure it and edited edit2 above with the results:

``-- Purpose: Determine the flow values at which the width of a river increases.
-- Usage: Locate a water course that flows through 3 world tiles horizontally
-- on the embark screen. The middle tile mustn't have any other river joining.
-- Then place the DF focus (i.e. the embark rectangle) in the middle tile and
-- invoke the script.

function rivermeasurer()
local x = df.global.gview.view.child.location.region_pos.x
local y = df.global.gview.view.child.location.region_pos.y
local river
local center
local found = false
local widhth
local previous_width = 0
local previous_index = 0
local tile_x = 8
local tile_y

for i, riv in ipairs (df.global.world.world_data.rivers) do
for k, pos_x in ipairs (riv.path.x) do
if x == pos_x and y == riv.path.y[k] then
river = i
center = k
found = true
break
end

  if found then
    break
  end
end

end

dfhack.println ("River: " .. tostring (river) .. " center world tile " .. tostring (center))

for i = 0, 15 do
if df.global.world.world_data.region_details[0].rivers_horizontal.active [tile_x] [i] ~= 0 then
tile_y = i
break
end
end

for i = 0, 100000 do
df.global.world.world_data.rivers[river].unk_8c [center - 1] = i
df.global.world.world_data.rivers[river].unk_8c [center] = i
df.global.world.world_data.rivers[river].unk_8c [center + 1] = i

df.global.gview.view.child:feed_key (df.interface_key.CURSOR_UP)	  
df.global.gview.view.child:feed_key (df.interface_key.CURSOR_DOWN)	  

width = df.global.world.world_data.region_details[0].rivers_horizontal.y_max [tile_x] [tile_y] -
        df.global.world.world_data.region_details[0].rivers_horizontal.y_min [tile_x] [tile_y] + 1
		
if width > previous_width then
  dfhack.println ("Width " .. tostring(width) ..  " at river flow " ..  tostring (i) .. " diff " .. tostring (i - previous_index))
  previous_width = width
  previous_index = i
  if width == 47 then
    break
  end
end

end
end

rivermeasurer()``

@PatrikLundell
Copy link
Contributor Author

Since I've created a pull request for the stuff above this Issue has been overtaken by events.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant