Last active
December 25, 2015 16:19
-
-
Save Putnam3145/7005495 to your computer and use it in GitHub Desktop.
Unmount for Rumrusher's mount here: https://gist.github.com/Rumrusher/6903877 Very, very adventurer-specific
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function unMount (rider,horse) | |
--for k,horse in pairs(unit_list) do | |
--if unit_rider.pos.x==horse.pos.x and unit_rider.pos.y==horse.pos.y | |
--and unit_rider.pos.z==horse.pos.z then --check if they are on the same tile | |
for i=#horse.general_refs-1,0,-1 do | |
if df.general_ref_unit_riderst:is_instance(horse.general_refs[i]) then horse.general_refs:erase(i) end | |
end | |
rider.relations.rider_mount_id=-1 | |
rider.flags1.rider=false | |
horse.flags1.ridden=false | |
for i=#df.global.world.units.other.ANY_RIDER-1,0,-1 do | |
if df.global.world.units.other.ANY_RIDER[i]==rider then df.global.world.units.other.ANY_RIDER:erase(i) end | |
end | |
return | |
end | |
function getRider(unit) | |
for k,v in ipairs(horse.general_refs) do | |
if df.general_ref_unit_riderst:is_instance(v) then return df.unit.find(v.unit_id) end | |
end | |
end | |
local selectedUnit=dfhack.gui.getSelectedUnit() | |
if not (selectedUnit.flags1.rider or selectedUnit.flags1.ridden) then | |
qerror("Unit needs either to be riding something or to be ridden by something!") | |
end | |
local otherUnit=selectedUnit.flags1.rider and df.unit.find(rider.relations.rider_mount_id) or getRider(selectedUnit) | |
dfhack.with_suspend(unMount, selectedUnit, otherUnit) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment