Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ Template for new versions:
## New Features

## Fixes
- `questport`: fix crash on current DF versions and make the teleport actually move the player in fast travel
- `reveal-adv-map`: fix live quest log map update when revealing or hiding the map
- `bodyswap`: fix "invalid argument count" when the target unit has no nemesis record
- `fix/loyaltycascade`: guard against citizens that are not historical figures and emit a warning.
- `gui/siegemanager`: fix nil index if there are no siege engines on the map
Expand Down
5 changes: 3 additions & 2 deletions docs/questport.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,13 @@ questport

.. dfhack-tool::
:summary: Teleport to your quest log map cursor.
:tags: unavailable
:tags: adventure armok map

If you open the quest log map and move the cursor to your target location, you
can run this command to teleport straight there. This can be done both within
and outside of fast travel mode, and it is possible to ``questport`` in
situations where fast travel is normally prohibited.
situations where fast travel is normally prohibited. The quest log map must be
zoomed out to the world map when running this command.

It is not possible to ``questport`` into inaccessible locations like ocean and
mountain tiles.
Expand Down
19 changes: 13 additions & 6 deletions questport.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ local function processTravelNoArmy(advmode, advScreen, target_x, target_y)
gui.simulateInput(advScreen.child, 'LEAVESCREEN') -- close map
gui.simulateInput(advScreen.child, 'LEAVESCREEN') -- close log
advmode.site_level_zoom = 1 -- zoom in to shrink the following travel movement, reducing the risk of failure
gui.simulateInput(advScreen, 'CURSOR_DOWN') -- the player army is only created once the player moves in travel mode; ensure that this movement occurs as the player will otherwise find themselves at their original location if they end travel mode immediately
gui.simulateInput(advScreen, 'A_MOVE_S') -- the player army is only created once the player moves in travel mode; ensure that this movement occurs as the player will otherwise find themselves at their original location if they end travel mode immediately
-- note: the above movement may be blocked by an impassable tile (especially if trying to teleport into a mountain range); it would be more ideal to create and move the player army directly instead
end

Expand All @@ -20,9 +20,14 @@ local advScreen = dfhack.gui.getViewscreenByType(df.viewscreen_dungeonmodest, 0)
local questMap = dfhack.gui.getViewscreenByType(df.viewscreen_adventure_logst, 0)
or qerror("You must first select your destination on the quest log map!")

local target_x = questMap.cursor.x
local target_y = questMap.cursor.y
if questMap.player_region.x == target_x and questMap.player_region.y == target_y then
local mapDisplay = questMap.map_display
if mapDisplay.midmap ~= 0 or mapDisplay.localmap ~= 0 then
qerror("Please zoom the quest log map out to the world map!")
end

local target_x = mapDisplay.cursor.x
local target_y = mapDisplay.cursor.y
if mapDisplay.cur_loc.x == target_x and mapDisplay.cur_loc.y == target_y then
qerror("You already seem to be at the target location!")
end

Expand All @@ -38,13 +43,15 @@ if advmode.menu == df.ui_advmode_menu.Default then
processTravelNoArmy(advmode, advScreen, target_x, target_y)

elseif advmode.menu == df.ui_advmode_menu.Travel then
if not advmode.travel_not_moved then -- player is already moving in fast travel mode; just relocate the player army
local army = df.army.find(advmode.player_army_id)
local army = df.army.find(advmode.player_army_id)
if advmode.travel_not_moved == 0 and army then -- player is already moving in fast travel mode; just relocate the player army
army.pos.x = target_x
army.pos.y = target_y
gui.simulateInput(advScreen.child, 'LEAVESCREEN') -- close map
gui.simulateInput(advScreen.child, 'LEAVESCREEN') -- close log
else -- player has opened travel mode but hasn't moved yet, so the player army hasn't been created
processTravelNoArmy(advmode, advScreen, target_x, target_y)
end
else
qerror("Please close the open menu before questporting!")
end
15 changes: 8 additions & 7 deletions reveal-adv-map.lua
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,16 @@ function revealAdvMap(hide)
-- update the quest log configuration if it is already open (restricts map cursor movement):
local view = dfhack.gui.getDFViewscreen(true)
if view._type == df.viewscreen_adventure_logst then
local player = view.player_region
local mapDisplay = view.map_display
local player = mapDisplay.cur_loc
if hide then
view.cursor.x = player.x
view.cursor.y = player.y
mapDisplay.cursor.x = player.x
mapDisplay.cursor.y = player.y
end
view.min_discovered.x = (hide and player.x) or 0
view.min_discovered.y = (hide and player.y) or 0
view.max_discovered.x = (hide and player.x) or world.world_width - 1
view.max_discovered.y = (hide and player.y) or world.world_height - 1
mapDisplay.min.x = (hide and player.x) or 0
mapDisplay.min.y = (hide and player.y) or 0
mapDisplay.max.x = (hide and player.x) or world.world_width - 1
mapDisplay.max.y = (hide and player.y) or world.world_height - 1
end
end

Expand Down