I'm currently playing some adventure-mode and looked for a way to get a bit of training without the stupid animal-bashing and without overpowering my char.
I took the make-legendary script and changed it to accept a second argument to set a specific skilllevel.
Maybe you find it useful, too...
-- Set a skill or skills of a unit to a given level
-- by cythev (based on make-legendary by vjek)
local help = [====[
setskill
==============
Sets the selected dwarf to a certain level in one skill, a group of skills, or all
skills. View groups with "setskill classes", or all skills with
"setskill list". Use "setskill MINING 10" when you need something
dug up, or "setskill all 20" when all skills should be at maximum.
]====]
-- this function will return the number of elements, starting at zero.
-- useful for counting things where #foo doesn't work
function count_this(to_be_counted)
local count = -1
local var1 = ""
while var1 ~= nil do
count = count + 1
var1 = (to_be_counted[count])
end
count=count-1
return count
end
function getName(unit)
return dfhack.df2console(dfhack.TranslateName(dfhack.units.getVisibleName(unit)))
end
function setskill(skillname,val)
local skillnamenoun,skillnum
unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.")
return
end
if (df.job_skill[skillname]) then
skillnamenoun = df.job_skill.attrs[df.job_skill[skillname]].caption_noun
else
print ("The skill name provided is not in the list.")
return
end
if skillnamenoun ~= nil then
utils = require 'utils'
skillnum = df.job_skill[skillname]
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = skillnum, rating = val }, 'id')
print (getName(unit) .. " is now Level ".. val .." ".. skillnamenoun)
else
print ("Empty skill name noun, bailing out!")
return
end
end
function PrintSkillList()
local count_max = count_this(df.job_skill)
local i
for i=0, count_max do
print("'"..df.job_skill.attrs.caption.."' "..df.job_skill.." Type: "..df.job_skill_class[df.job_skill.attrs.type])
end
print ("Provide the UPPER CASE argument, for example: PROCESSPLANTS rather than Threshing")
end
function BreathOfArmok(val)
unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.")
return
end
local i
local count_max = count_this(df.job_skill)
utils = require 'utils'
for i=0, count_max do
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = val }, 'id')
end
print ("The breath of Armok has engulfed "..getName(unit))
end
function LegendaryByClass(skilltype,val)
unit=dfhack.gui.getSelectedUnit()
if unit==nil then
print ("No unit under cursor! Aborting with extreme prejudice.")
return
end
utils = require 'utils'
local i
local skillclass
local count_max = count_this(df.job_skill)
for i=0, count_max do
skillclass = df.job_skill_class[df.job_skill.attrs.type]
if skilltype == skillclass then
print ("Skill "..df.job_skill.attrs.caption.." is type: "..skillclass.." and is now Legendary for "..getName(unit))
utils.insert_or_update(unit.status.current_soul.skills, { new = true, id = i, rating = val }, 'id')
end
end
end
function PrintSkillClassList()
local i
local count_max = count_this(df.job_skill_class)
for i=0, count_max do
print(df.job_skill_class)
end
print ("Provide one of these arguments, and all skills of that type will be set to desired Level")
print ("For example: \"Medical 20\" will make all medical skills legendary")
end
--main script operation starts here
----
local opt = ...
local val = select(2,...)
local skillname
if val==nil then
print("No specific value provided. will assume legendary level 20.")
val = 20
end
if opt then
if opt=="list" then
PrintSkillList()
return
end
if opt=="classes" then
PrintSkillClassList()
return
end
if opt=="all" then
BreathOfArmok(val)
return
end
if opt=="Normal" or opt=="Medical" or opt=="Personal" or opt=="Social" or opt=="Cultural" or opt=="MilitaryWeapon" or opt=="MilitaryAttack" or opt=="MilitaryDefense" or opt=="MilitaryMisc" then
LegendaryByClass(opt,val)
return
end
skillname = opt
else
print(help)
return
end
setskill(skillname,val)