Merge remote-tracking branch 'warmist/master'

Conflicts:
	plugins/Dfusion/include/OutFile.h
develop
Alexander Gavrilov 2012-11-12 10:50:48 +04:00
commit c32f85d637
5 changed files with 165 additions and 21 deletions

@ -13,11 +13,16 @@ DFHack future
New scripts:
- binpatch: the same as the stand-alone binpatch.exe, but works at runtime.
- region-pops: displays animal populations of the region and allows tweaking them.
- lua: lua interpreter.
- dfusion: misc scripts with a text based menu.
- embark: lets you embark anywhere.
New GUI scripts:
- gui/guide-path: displays the cached path for minecart Guide orders.
- gui/workshop-job: displays inputs of a workshop job and allows tweaking them.
- gui/workflow: a front-end for the workflow plugin.
- gui/assign-rack: works together with a binary patch to fix weapon racks.
- gui/gm-editor: an universal editor for lots of dfhack things.
- gui/companion-order: a adventure mode command interface for your companions.
Workflow plugin:
- properly considers minecarts assigned to routes busy.
- code for deducing job outputs rewritten in lua for flexibility.
@ -30,7 +35,8 @@ DFHack future
properly designated barracks be used again for storage of squad equipment.
New Search plugin by falconne:
Adds an incremental search function to the Stocks, Trading and Unit List screens.
Dfusion plugin:
Reworked to make use of lua modules, now all the scripts can be used from other scripts.
DFHack v0.34.11-r2

@ -1685,19 +1685,17 @@ twice.
dfusion
-------
This is the DFusion lua plugin system by warmist/darius, running as a DFHack plugin.
This is the DFusion lua plugin system by Warmist, running as a DFHack plugin. There are two parts to this plugin: an interactive script that shows a text based menu and lua modules. Some of the functionality of is intentionaly left out of the menu:
:Friendship: a binary plugin that allows multi race forts (to use make a script that imports plugins.dfusion.friendship and use Friendship:install{table} table should contain list of race names.)
:Embark: a binary plugin that allows multi race embark (to use make a script that imports plugins.dfusion.embark and use Embark:install{table} table should contain list of race names or list of pairs (race-name, caste_id)).
See the bay12 thread for details: http://www.bay12forums.com/smf/index.php?topic=69682.15
See the bay12 thread for details: http://www.bay12forums.com/smf/index.php?topic=93317.0
Confirmed working DFusion plugins:
:simple_embark: allows changing the number of dwarves available on embark.
.. note::
* Some of the DFusion plugins aren't completely ported yet. This can lead to crashes.
* This is currently working only on Windows.
* The game will be suspended while you're using dfusion. Don't panic when it doen't respond.
* The game will be suspended while you're using dfusion. Don't panic when it doesn't respond.
misery
------
@ -1921,6 +1919,16 @@ deathcause
Focus a body part ingame, and this script will display the cause of death of
the creature.
lua
===
There are three ways to invoke this command:
1. without any parameters - starts an interactive lua interpreter
2. -f "filename" or --file "filename" - loads and runs the file indicated by filename
3. -s ["filename"] or --save ["filename"] - loads and runs the file indicated by filename from save directory. If filename is not supplied it loads "dfhack.lua"
embark
======
Allows to embark anywhere. Currently windows only.
=======================
In-game interface tools

@ -105,7 +105,7 @@ public:
void GetText(char *ptr);
size_t GetTextSize();
void LoadSymbols();
const vSymbol &GetSymbols(){LoadSymbols();return symbols;};
const vSymbol& GetSymbols(){LoadSymbols();return symbols;};
void PrintSymbols();
void PrintRelocations();
protected:

@ -94,8 +94,8 @@ function MakeFollow(unit,trgunit)
trgunit=df.global.world.units.active[0]
end
unit.relations.group_leader_id=trgunit.id
local u_nem=getNemesis(unit)
local t_nem=getNemesis(trgunit)
local u_nem=dfhack.units.getNemesis(unit)
local t_nem=dfhack.units.getNemesis(trgunit)
if u_nem then
u_nem.group_leader_id=t_nem.id
end
@ -150,13 +150,8 @@ function project(unit,trg) --TODO add to menu?
end
function empregnate(unit)
if unit==nil then
unit=getSelectedUnit()
end
if unit==nil then
unit=getCreatureAtPos(getxyz())
unit=dfhack.gui.getSelectedUnit()
end
if unit==nil then
error("Failed to empregnate. Unit not selected/valid")
end
@ -182,4 +177,67 @@ function empregnate(unit)
unit.relations.pregnancy_mystery=1
end
menu:add("Empregnate",empregnate)
function healunit(unit)
if unit==nil then
unit=dfhack.gui.getSelectedUnit()
end
if unit==nil then
error("Failed to Heal unit. Unit not selected/valid")
end
unit.body.wounds:resize(0) -- memory leak here :/
unit.body.blood_count=unit.body.blood_max
--set flags for standing and grasping...
unit.status2.able_stand=4
unit.status2.able_stand_impair=4
unit.status2.able_grasp=4
unit.status2.able_grasp_impair=4
--should also set temperatures, and flags for breath etc...
unit.flags1.dead=false
unit.flags2.calculated_bodyparts=false
unit.flags2.calculated_nerves=false
unit.flags2.circulatory_spray=false
unit.flags2.vision_good=true
unit.flags2.vision_damaged=false
unit.flags2.vision_missing=false
unit.counters.winded=0
unit.counters.unconscious=0
for k,v in pairs(unit.body.components) do
for kk,vv in pairs(v) do
if k == 'body_part_status' then v[kk].whole = 0 else v[kk] = 0 end
end
end
end
menu:add("Heal unit",healunit)
function powerup(unit,labor_rating,military_rating,skills)
if unit==nil then
unit=dfhack.gui.getSelectedUnit()
end
if unit==nil then
error("Failed to power up unit. Unit not selected/valid")
end
if unit.status.current_soul== nil then
error("Failed to power up unit. Unit has no soul")
end
local utils = require 'utils'
labor_rating = labor_rating or 15
military_rating = military_rating or 70
skill =skill or { 0,2,3,4,5,6,7,8,9,10,11,12,13,14,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,41,42,43,44,45,46,47,48,49,54,55,57,58,59,60,61,62,63,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,95,96,97,98,99,100,101,102,103,104,105,109,110,111,112,113,114,115 }
local military = { 38,39,41,42,43,44,45,46,54,99,100,101,102,103,104,105 }
for sk,sv in ipairs(skill) do
local new_rating = labor_rating
for _,v in ipairs(military) do
if v == sv then
local new_rating = military_rating
end
end
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = sv, rating = new_rating, experience = (new_rating * 500) + (new_rating * (new_rating - 1)) * 50}, 'id')
end
end
menu:add("Power up",powerup)
return _ENV

@ -1,11 +1,13 @@
local gui = require 'gui'
local dlg = require 'gui.dialogs'
local args={...}
local is_cheat=(#args>0 and args[1]=="-c")
local cursor=xyz2pos(df.global.cursor.x,df.global.cursor.y,df.global.cursor.z)
local permited_equips={}
permited_equips[df.item_backpackst]="UPPERBODY"
permited_equips[df.item_quiverst]="UPPERBODY"
permited_equips[df.item_flaskst]="UPPERBODY"
permited_equips[df.item_armorst]="UPPERBODY"
permited_equips[df.item_shoesst]="STANCE"
@ -13,7 +15,7 @@ permited_equips[df.item_glovesst]="GRASP"
permited_equips[df.item_helmst]="HEAD"
permited_equips[df.item_pantsst]="LOWERBODY"
function DoesHaveSubtype(item)
if df.item_backpackst:is_instance(item) or df.item_flaskst:is_instance(item) then
if df.item_backpackst:is_instance(item) or df.item_flaskst:is_instance(item) or df.item_quiverst:is_instance(item) then
return false
end
return true
@ -28,6 +30,13 @@ function CheckCursor(p)
end
return true
end
function getxyz() -- this will return pointers x,y and z coordinates.
local x=df.global.cursor.x
local y=df.global.cursor.y
local z=df.global.cursor.z
return x,y,z -- return the coords
end
function GetCaste(race_id,caste_id)
local race=df.creature_raw.find(race_id)
return race.caste[caste_id]
@ -255,6 +264,26 @@ end},
end
return true
end},
{name="unwield",f=function (unit_list)
for k,v in pairs(unit_list) do
local wep_count=0
for _,it in pairs(v.inventory) do
if it.mode==1 then
wep_count=wep_count+1
end
end
for i=1,wep_count do
for _,it in pairs(v.inventory) do
if it.mode==1 then
dfhack.items.moveToGround(it.item,v.pos)
break
end
end
end
end
return true
end},
--[=[
{name="roam not working :<",f=function (unit_list,pos,dist) --does not work
if not CheckCursor(pos) then
@ -302,8 +331,39 @@ end},
end
return true
end},
}
local cheats={
{name="Patch up",f=function (unit_list)
local dft=require("plugins.dfusion.tools")
for k,v in pairs(unit_list) do
dft.healunit(v)
end
return true
end},
{name="Power up",f=function (unit_list)
local dft=require("plugins.dfusion.tools")
for k,d in pairs(unit_list) do
dft.powerup(d)
end
return true
end},
{name="get in",f=function (unit_list,pos)
if not CheckCursor(pos) then
return false
end
adv=df.global.world.units.active[0]
item=getItemsAtPos(getxyz())[1]
print(item.id)
for k,v in pairs(unit_list) do
v.riding_item_id=item.id
local ref=df.general_ref_unit_riderst:new()
ref.unit_id=v.id
item.itemrefs:insert("#",ref)
end
return true
end},
}
local cheats={}
--[[ todo: add cheats...]]--
function getCompanions(unit)
unit=unit or df.global.world.units.active[0]
@ -371,7 +431,14 @@ function CompanionUi:onInput(keys)
self:dismiss()
end
end
--do order
if is_cheat then
idx=idx-#orders
if cheats[idx] and cheats[idx].f then
if cheats[idx].f(self:GetSelectedUnits(),cursor) then
self:dismiss()
end
end
end
end
end
end
@ -393,6 +460,11 @@ function CompanionUi:onRenderBody( dc)
for k,v in ipairs(orders) do
dc:seek(w/2,k):string(string.char(k+char_A)..". "):string(v.name);
end
if is_cheat then
for k,v in ipairs(cheats) do
dc:seek(w/2,k+#orders):string(string.char(k+#orders+char_A)..". "):string(v.name);
end
end
end
local screen=CompanionUi{unit_list=getCompanions()}
screen:show()