advfort: siege weapon and trap fixes

develop
Warmist 2015-01-26 22:35:46 +02:00
parent b2b1a6e844
commit f3811c4772
1 changed files with 30 additions and 26 deletions

@ -1,8 +1,10 @@
-- allows to do jobs in adv. mode. -- allows to do jobs in adv. mode.
--[==[ --[==[
version: 0.012 version: 0.013
changelog: changelog:
*0.013
- fixed siege weapons and traps (somewhat). Now you can load them with new menu :)
*0.012 *0.012
- fix for some jobs not finding correct building. - fix for some jobs not finding correct building.
*0.011 *0.011
@ -21,6 +23,10 @@
- kind-of fixed the item problem... now they get teleported (if teleport_items=true which should be default for adventurer) - kind-of fixed the item problem... now they get teleported (if teleport_items=true which should be default for adventurer)
- gather plants still not working... Other jobs seem to work. - gather plants still not working... Other jobs seem to work.
- added new-and-improved waiting. Interestingly it could be improved to be interuptable. - added new-and-improved waiting. Interestingly it could be improved to be interuptable.
todo list:
- document everything! Maybe somebody would understand what is happening then and help me :<
- when building trap add to known traps (or known adventurers?) so that it does not trigger on adventurer
--]==] --]==]
--keybinding, change to your hearts content. Only the key part. --keybinding, change to your hearts content. Only the key part.
@ -720,7 +726,7 @@ function finish_item_assign(args)
end end
end end
function AssignJobItems(args) function AssignJobItems(args)
print("----") --print("----")
if settings.df_assign then --use df default logic and hope that it would work if settings.df_assign then --use df default logic and hope that it would work
return true return true
end end
@ -773,13 +779,13 @@ function AssignJobItems(args)
end end
end end
end end
print("before block") --print("before block")
if settings.gui_item_select and #job.job_items>0 then if settings.gui_item_select and #job.job_items>0 then
local item_dialog=require('hack.scripts.gui.advfort_items') local item_dialog=require('hack.scripts.gui.advfort_items')
--local rr=require('gui.script').start(function() --local rr=require('gui.script').start(function()
print("before dialog") --print("before dialog")
local ret=item_dialog.showItemEditor(job,item_suitability) local ret=item_dialog.showItemEditor(job,item_suitability)
print("post dialog",ret) --print("post dialog",ret)
--showItemEditor(job,item_suitability) --showItemEditor(job,item_suitability)
if ret then if ret then
finish_item_assign(args) finish_item_assign(args)
@ -1007,40 +1013,37 @@ function onWorkShopJobChosen(args,idx,choice)
args.pre_actions={dfhack.curry(setFiltersUp,choice.filter),AssignJobItems} args.pre_actions={dfhack.curry(setFiltersUp,choice.filter),AssignJobItems}
makeJob(args) makeJob(args)
end end
function siegeWeaponActionChosen(building,actionid) function siegeWeaponActionChosen(args,actionid)
local args local building=args.building
if actionid==1 then if actionid==1 then --Tunr
building.facing=(building.facing+1)%4 building.facing=(args.building.facing+1)%4
elseif actionid==2 then return
elseif actionid==2 then --Load
local action=df.job_type.LoadBallista local action=df.job_type.LoadBallista
if building:getSubtype()==df.siegeengine_type.Catapult then if building:getSubtype()==df.siegeengine_type.Catapult then
action=df.job_type.LoadCatapult action=df.job_type.LoadCatapult
args.pre_actions={dfhack.curry(setFiltersUp,{items={{quantity=1}}}),AssignJobItems} --TODO just boulders here
else
args.pre_actions={dfhack.curry(setFiltersUp,{items={{quantity=1,item_type=df.SIEGEAMMO}}}),AssignJobItems}
end end
args={}
args.job_type=action args.job_type=action
args.unit=df.global.world.units.active[0] args.unit=df.global.world.units.active[0]
local from_pos={x=args.unit.pos.x,y=args.unit.pos.y, z=args.unit.pos.z} local from_pos={x=args.unit.pos.x,y=args.unit.pos.y, z=args.unit.pos.z}
args.from_pos=from_pos args.from_pos=from_pos
args.pos=from_pos args.pos=from_pos
args.pre_actions={dfhack.curry(setFiltersUp,{items={{}}})} elseif actionid==3 then --Fire
--issue a job...
elseif actionid==3 then
local action=df.job_type.FireBallista local action=df.job_type.FireBallista
if building:getSubtype()==df.siegeengine_type.Catapult then if building:getSubtype()==df.siegeengine_type.Catapult then
action=df.job_type.FireCatapult action=df.job_type.FireCatapult
end end
args={}
args.job_type=action args.job_type=action
args.unit=df.global.world.units.active[0] args.unit=df.global.world.units.active[0]
local from_pos={x=args.unit.pos.x,y=args.unit.pos.y, z=args.unit.pos.z} local from_pos={x=args.unit.pos.x,y=args.unit.pos.y, z=args.unit.pos.z}
args.from_pos=from_pos args.from_pos=from_pos
args.pos=from_pos args.pos=from_pos
--another job?
end
if args~=nil then
args.post_actions={AssignBuildingRef}
makeJob(args)
end end
args.post_actions={AssignBuildingRef}
makeJob(args)
end end
function putItemToBuilding(building,item) function putItemToBuilding(building,item)
if building:getType()==df.building_type.Table then if building:getType()==df.building_type.Table then
@ -1063,8 +1066,9 @@ function usetool:openPutWindow(building)
dialog.showListPrompt("Item choice", "Choose item to put into:", COLOR_WHITE,choices,function (idx,choice) putItemToBuilding(building,choice.item) end) dialog.showListPrompt("Item choice", "Choose item to put into:", COLOR_WHITE,choices,function (idx,choice) putItemToBuilding(building,choice.item) end)
end end
function usetool:openSiegeWindow(building) function usetool:openSiegeWindow(building)
local args={building=building,screen=self}
dialog.showListPrompt("Engine job choice", "Choose what to do:",COLOR_WHITE,{"Turn","Load","Fire"}, dialog.showListPrompt("Engine job choice", "Choose what to do:",COLOR_WHITE,{"Turn","Load","Fire"},
dfhack.curry(siegeWeaponActionChosen,building)) dfhack.curry(siegeWeaponActionChosen,args))
end end
function usetool:onWorkShopButtonClicked(building,index,choice) function usetool:onWorkShopButtonClicked(building,index,choice)
local adv=df.global.world.units.active[0] local adv=df.global.world.units.active[0]
@ -1159,17 +1163,17 @@ function usetool:armCleanTrap(building)
end end
--building.trap_type==df.trap_type.PressurePlate then --building.trap_type==df.trap_type.PressurePlate then
--settings/link --settings/link
local args={unit=adv,post_actions={AssignBuildingRef,AssignJobItems},pos=adv.pos,from_pos=adv.pos, local args={unit=adv,post_actions={AssignBuildingRef},pos=adv.pos,from_pos=adv.pos,
building=building,job_type=df.job_type.CleanTrap} building=building,job_type=df.job_type.CleanTrap}
if building.trap_type==df.trap_type.CageTrap then if building.trap_type==df.trap_type.CageTrap then
args.job_type=df.job_type.LoadCageTrap args.job_type=df.job_type.LoadCageTrap
local job_filter={items={{quantity=1,item_type=df.item_type.CAGE}} } local job_filter={items={{quantity=1,item_type=df.item_type.CAGE}} }
args.pre_actions={dfhack.curry(setFiltersUp,job_filter)} args.pre_actions={dfhack.curry(setFiltersUp,job_filter),AssignJobItems}
elseif building.trap_type==df.trap_type.StoneFallTrap then elseif building.trap_type==df.trap_type.StoneFallTrap then
args.job_type=df.job_type.LoadStoneTrap args.job_type=df.job_type.LoadStoneTrap
local job_filter={items={{quantity=1,item_type=df.item_type.BOULDER}} } local job_filter={items={{quantity=1,item_type=df.item_type.BOULDER}} }
args.pre_actions={dfhack.curry(setFiltersUp,job_filter)} args.pre_actions={dfhack.curry(setFiltersUp,job_filter),AssignJobItems}
elseif building.trap_type==df.trap_type.WeaponTrap then elseif building.trap_type==df.trap_type.WeaponTrap then
qerror("TODO") qerror("TODO")
else else
@ -1181,10 +1185,10 @@ function usetool:armCleanTrap(building)
end end
function usetool:hiveActions(building) function usetool:hiveActions(building)
local adv=df.global.world.units.active[0] local adv=df.global.world.units.active[0]
local args={unit=adv,post_actions={AssignBuildingRef,AssignJobItems},pos=adv.pos, local args={unit=adv,post_actions={AssignBuildingRef},pos=adv.pos,
from_pos=adv.pos,job_type=df.job_type.InstallColonyInHive,building=building,screen=self} from_pos=adv.pos,job_type=df.job_type.InstallColonyInHive,building=building,screen=self}
local job_filter={items={{quantity=1,item_type=df.item_type.VERMIN}} } local job_filter={items={{quantity=1,item_type=df.item_type.VERMIN}} }
args.pre_actions={dfhack.curry(setFiltersUp,job_filter)} args.pre_actions={dfhack.curry(setFiltersUp,job_filter),AssignJobItems}
makeJob(args) makeJob(args)
--InstallColonyInHive, --InstallColonyInHive,
--CollectHiveProducts, --CollectHiveProducts,