Woooooooooooh
TheFalcon: Errm, I've just found out how to change the wilderness borders, so all that testing and stuff was pretty useless...
cave(j,i).mimic = 0
As simple as that...
It's because the borders are done as mimic features on top of the plain permanent brick wall. So changing the feature did not show up as the mimic was still on top. I just need to take off the mimic, then any changes to the borders show up. Or I can just change the mimic feature I guess.
This means that I don't need to bother doing the wilderness generation, and can just stick to localised border changes.
Which is kind of a relief, as it means I can get on with adding the actual features for Annals of Ea.
It's still something to bear in mind for a rainy day though. ;)
Here's my hack script, simply for history's sake...
It shows how to track the player across the wild_map and teleport them, and how to darken squares.
I've commented each function so you can tell what it does...
-- This function is the one that darkens the grids. it finds out whether the grids are light, and only does so then.
-- Notice the restricting couter, to stop it being called every game turn. I was going to revise this, so it
-- wouldn't be buggy at high player speeds...
function hack()
local i, j
if (player.wild_mode == FALSE) then
turn_count = turn_count + 1
end
if (player.wild_mode == FALSE) and (dun_level == 0) and (turn_count >= 10) then
for i = 0, 198 do
j = 0
if (cave(j,i).info == bor(cave(j,i).info, CAVE_GLOW)) then
cave(j,i).info = band(cave(j,i).info, bnot(CAVE_GLOW))
end
if (cave(j,i).info == bor(cave(j,i).info, CAVE_MARK)) then
cave(j,i).info = band(cave(j,i).info, bnot(CAVE_MARK))
end
j = 65
if (cave(j,i).info == bor(cave(j,i).info, CAVE_GLOW)) then
cave(j,i).info = band(cave(j,i).info, bnot(CAVE_GLOW))
end
if (cave(j,i).info == bor(cave(j,i).info, CAVE_MARK)) then
cave(j,i).info = band(cave(j,i).info, bnot(CAVE_MARK))
end
end
for j = 1, 64 do
i = 0
if (cave(j,i).info == bor(cave(j,i).info, CAVE_GLOW)) then
cave(j,i).info = band(cave(j,i).info, bnot(CAVE_GLOW))
end
if (cave(j,i).info == bor(cave(j,i).info, CAVE_MARK)) then
cave(j,i).info = band(cave(j,i).info, bnot(CAVE_MARK))
end
i = 197
if (cave(j,i).info == bor(cave(j,i).info, CAVE_GLOW)) then
cave(j,i).info = band(cave(j,i).info, bnot(CAVE_GLOW))
end
if (cave(j,i).info == bor(cave(j,i).info, CAVE_MARK)) then
cave(j,i).info = band(cave(j,i).info, bnot(CAVE_MARK))
end
end
turn_count = 0
player.redraw = bor(player.redraw, PR_MAP)
-- player.update = bor(player.update, PU_VIEW)
end
end
add_hook_script(HOOK_END_TURN, "hack", "hack")
add_hook_script(HOOK_WILD_GEN, "hack", "hack")
add_loadsave("turn_count", 0)
-- Restricting counter reset if change wild_mode, so the darkening hack works.
function hack1_helper()
turn_count = 10
end
add_hook_script(HOOK_WILD_GEN, "hack1_helper", "hack1_helper")
-- This function acts when the player moves towards one of the new borders, and teleports them to the correct place
-- on the next square. I would need to restric this to avoid world-map border hopping. Debug messages are still in...
function hack2(y, x)
if (player.wild_mode == FALSE) and (dun_level == 0) and (((player.py < 3) or (player.py > 61)) or ((player.px < 3) or (player.px > 193))) then
if (y==1) and (x~=1) and (x~=196) then
player.wilderness_y = player.wilderness_y - 1
player.wild_mode = FALSE
player.px = player.px
player.py = 63
player.oldpy = player.py
dun_level = 0
player.leaving = TRUE
msg_print("Moving North")
return TRUE
elseif (y==64) and (x~=1) and (x~=196) then
player.wilderness_y = player.wilderness_y + 1
player.wild_mode = FALSE
player.py = 2
player.oldpx = player.px
player.oldpy = player.py
dun_level = 0
player.leaving = TRUE
msg_print("Moving South")
return TRUE
elseif (x==1) and (y~=1) and (y~=64) then
player.wilderness_x = player.wilderness_x - 1
player.wild_mode = FALSE
player.px = 195
player.oldpx = player.px
player.oldpy = player.py
dun_level = 0
player.leaving = TRUE
msg_print("Moving West")
return TRUE
elseif (x==196) and (y~=1) and (y~=64) then
player.wilderness_x = player.wilderness_x + 1
player.wild_mode = FALSE
player.px = 2
player.oldpx = player.px
player.oldpy = player.py
dun_level = 0
player.leaving = TRUE
msg_print("Moving East")
return TRUE
elseif (x==1) and (y==1) then
player.wilderness_x = player.wilderness_x - 1
player.wilderness_y = player.wilderness_y - 1
player.py = 63
player.px = 195
player.oldpy = player.py
player.oldpx = player.px
dun_level = 0
player.leaving = TRUE
msg_print("Moving North East")
return TRUE
elseif (x==1) and (y==64) then
player.wilderness_x = player.wilderness_x - 1
player.wilderness_y = player.wilderness_y + 1
player.py = 2
player.px = 195
player.oldpy = player.py
player.oldpx = player.px
dun_level = 0
player.leaving = TRUE
msg_print("Moving South East")
return TRUE
elseif (x==196) and (y==64) then
player.wilderness_x = player.wilderness_x + 1
player.wilderness_y = player.wilderness_y + 1
player.py = 2
player.px = 2
player.oldpy = player.py
player.oldpx = player.px
dun_level = 0
player.leaving = TRUE
msg_print("Moving South West")
return TRUE
elseif (x==196) and (y==1) then
player.wilderness_x = player.wilderness_x + 1
player.wilderness_y = player.wilderness_y - 1
player.py = 63
player.px = 2
player.oldpy = player.py
player.oldpx = player.px
dun_level = 0
player.leaving = TRUE
msg_print("Moving North West")
return TRUE
end
end
end
add_hook_script(HOOK_MOVE, "hack2", "hack2")
-- This is the script to track the player's movement on the wilderness map, to decide where to place them when they
-- move out of the small map.
function hack3()
if (player.wild_mode == FALSE) and ((oldpx ~= 0) or (oldpy ~=0)) then
if (px < oldpx) then
player.px = 195
player.oldpx = 195
msg_print("E")
elseif (px == oldpx) then
player.px = 98
player.oldpx = 98
msg_print("Mid")
elseif (px > oldpx) then
player.px = 2
player.oldpy = 2
msg_print("W")
end
if (py < oldpy) then
player.py = 63
player.oldpy = 63
msg_print("S")
elseif (py == oldpy) then
player.py = 31
player.oldpy = 31
msg_print("Mid")
elseif (py > oldpy) then
player.py = 2
player.oldpy = 2
msg_print("N")
end
end
hack3_helper2()
end
add_hook_script(HOOK_WILD_GEN, "hack3", "hack3")
-- Helper: stores the old variables, and takes the new ones.
function hack3_helper()
if (player.wild_mode == TRUE) then
oldpx = px
oldpy = py
px = player.px
py = player.py
-- msg_print(format("px = %s, py = %s, oldpx = %s, oldpy = %s", px, py, oldpx, oldpy))
end
end
add_hook_script(HOOK_MOVED, "hack3_helper", "hack3_helper")
-- loadsaves for the tracker.
add_loadsave("px", 0)
add_loadsave("py", 0)
add_loadsave("oldpx", 0)
add_loadsave("oldpy", 0)
-- Called at wild_gen time to make sure the tracker is reset.
function hack3_helper2()
oldpx = 0
oldpy = 0
end
ToME Wiki