Added cheat commands to companion-order, (including rumrushers)

develop
Warmist 2012-11-11 21:18:59 +02:00
parent df3b791665
commit 3eb852a43b
2 changed files with 118 additions and 9 deletions

@ -150,13 +150,8 @@ function project(unit,trg) --TODO add to menu?
end end
function empregnate(unit) function empregnate(unit)
if unit==nil then if unit==nil then
unit=getSelectedUnit() unit=dfhack.gui.getSelectedUnit()
end
if unit==nil then
unit=getCreatureAtPos(getxyz())
end end
if unit==nil then if unit==nil then
error("Failed to empregnate. Unit not selected/valid") error("Failed to empregnate. Unit not selected/valid")
end end
@ -182,4 +177,67 @@ function empregnate(unit)
unit.relations.pregnancy_mystery=1 unit.relations.pregnancy_mystery=1
end end
menu:add("Empregnate",empregnate) 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 return _ENV

@ -1,7 +1,8 @@
local gui = require 'gui' local gui = require 'gui'
local dlg = require 'gui.dialogs' 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 cursor=xyz2pos(df.global.cursor.x,df.global.cursor.y,df.global.cursor.z)
local permited_equips={} local permited_equips={}
@ -28,6 +29,13 @@ function CheckCursor(p)
end end
return true return true
end 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) function GetCaste(race_id,caste_id)
local race=df.creature_raw.find(race_id) local race=df.creature_raw.find(race_id)
return race.caste[caste_id] return race.caste[caste_id]
@ -302,8 +310,39 @@ end},
end end
return true return true
end}, 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={
{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},
} }
local cheats={}
--[[ todo: add cheats...]]-- --[[ todo: add cheats...]]--
function getCompanions(unit) function getCompanions(unit)
unit=unit or df.global.world.units.active[0] unit=unit or df.global.world.units.active[0]
@ -371,7 +410,14 @@ function CompanionUi:onInput(keys)
self:dismiss() self:dismiss()
end end
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 end
end end
@ -393,6 +439,11 @@ function CompanionUi:onRenderBody( dc)
for k,v in ipairs(orders) do for k,v in ipairs(orders) do
dc:seek(w/2,k):string(string.char(k+char_A)..". "):string(v.name); dc:seek(w/2,k):string(string.char(k+char_A)..". "):string(v.name);
end 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 end
local screen=CompanionUi{unit_list=getCompanions()} local screen=CompanionUi{unit_list=getCompanions()}
screen:show() screen:show()