v50 Steam/Premium information for editors
  • v50 information can now be added to pages in the main namespace. v0.47 information can still be found in the DF2014 namespace. See here for more details on the new versioning policy.
  • Use this page to report any issues related to the migration.
This notice may be cached—the current version can be found here.

Difference between revisions of "User:Andux/Scripts"

From Dwarf Fortress Wiki
Jump to navigation Jump to search
m (→‎Name generator: using find() method)
(→‎HealUnit: update for r3)
Line 178: Line 178:
  
 
print("Resetting status flags...")
 
print("Resetting status flags...")
unit.status2.able_stand_impair=unit.status2.able_stand
+
 
unit.status2.able_grasp_impair=unit.status2.able_grasp
+
-- for DFHack >= 0.34.11 r3
 +
unit.status2.limbs_stand_count=unit.status2.limbs_stand_max
 +
unit.status2.limbs_grasp_count=unit.status2.limbs_grasp_max
 +
-- for older versions, use these instead:
 +
--unit.status2.able_stand_impair=unit.status2.able_stand
 +
--unit.status2.able_grasp_impair=unit.status2.able_grasp
  
 
unit.flags2.has_breaks=false
 
unit.flags2.has_breaks=false

Revision as of 00:52, 21 May 2013

A collection of scripts for DFHack.

Fortress mode

Name generator

Based on Aerval's; changes:

  • Expanded selection of name parts.
  • Uses the world's name seed instead of the dwarf race index.
  • Better handling of historical figures.
--Nameparts by http://jtevans.kilnar.com/rpg/dnd/tools/dwarf.php, Aerval, and Andux
local firstnamepart = {
	"ad", "ak", "an", "ar", "ash", "at",
	"ba", "bal", "bar", "bel", "ber", "bil", "bof", "bol", "bro", "bul",
	"cal", "chal",
	"da", "das", "dal", "dim", "dor", "dru", "dur", "dwe", "dwin",
	"el",
	"fal", "far", "fash", "fel", "fim", "ful", "fun",
	"gal", "gar", "ger", "gil", "gim", "gom", "gol", "gri", "gro", "gru", "grun",
	"ha", "hal", "ham", "har", "hel", "her", "ho", "hol", "hor", "hul",
	"ing", "in", "ir",

	"kal", "kas", "ket", "kha", "khor", "kil", "kin", "ko", "kor", "kul",
	"lam", "lar", "lon", "lun",
	"mag", "mal", "mar", "mor", "mun",
	"nal", "nar", "nil", "nor",
	"ol", "or", "ov",

	"rag", "ral", "ram", "rim", "ron", "run", 
	"sal", "sar", "shal", "shar", "shor", "sim", "sor", "stal", "stav", "sven",
	"tan", "tha", "thal", "thin", "thor", "thra", "thu", 
	"um", "ur",
	"val", "van",
	"wil",

	"yar",
	"za", "zir", "zul"
};
local female_secondpart = {
	"a", "ada", "ala", "ana", "ani", "atha",
	"bari", "bina", "bine", "bura", 
	"cha", "chi",
	"da", "dana", "dani", "dili", "dina", "dola", "dora", "dri", "dria", 
	"edi", "ena", "eta", "eva", "eza",
	"fani", "fi",
	"ga", "gana", "gari", "gela", "gina", "gini", "goli", "grima", 

	"i", "ia", "ida", "ila", "ilda", "ili", "ika", "ina", "iri",

	"ka", "ki", "kia", "kona", "kuni",
	"la", "lani", "leda", "lena", "lia", "lina", "lona",
	"ma", "mani", "mela", "mina", "moda", "modi",
	"na", "neva", "ni", "nia", "nomi",
	"ola", "olga", "ona", "ondi", "oti", "ova",

	"ra", "raka", "rana", "ravi", "ri", "ria", "rimi", "rinda", "rundi", 
	"sha", "shi", "si", "ska",
	"ta", "tha", "ti", "tila", "tri", "tria", 
	"umma", "undi", "unga", "unni", 
	"vala", "vali", "vara", "vari", "vina",
	"ya",
	"zadi", "zani", "zara", "zi"
};
local male_secondpart = {
	"aim", "ain", "ak", "ald", "am", "ar", "ard", "ash", 
	"bain", "bald", "ban", "bar", "bash", "brun", "bur", 

	"dain", "dall", "dar", "din", "dok", "dol", "dor", "dum", "dun", "dur",
	"eff", "esh", "ev",
	"far", "fath", "feb",
	"gan", "gar", "gath", "gin", "gor", "grim", 

	"ik", "il", "im", "in", "ip", "isch", 

	"kad", "kar", "kash", "keld", "kesh", "kon", 
	"lek", "lem", "lesh", "let", "leth", "lin", "lor", 
	"mar", "mek", "min", "mok", "mon", "moth", "mund", 
	"nar", "nek", "nir", "nod", "nor", 
	"od", "oin", "ok", "old", "on", "ond", "or", 

	"rak", "ram", "rik", "rim", "rin", "ros", "roth", "rund", 
	"skal", "skar",
	"tar", "tek", "til", "tok", "tul",
	"um", "und", "unn", "ur", "urd",
	"val", "van", "var", "vath", "vek", "ven", "vesh", "veth", "vin", "von",

	"zad", "zar", "zek", "zim", "zin"
};

local dwarfRace = df.global.ui.race_id;

math.randomseed(tonumber(df.global.world.worldgen.worldgen_parms.name_seed,36));
for index,unit in pairs(df.global.world.history.figures) do --Renaming all the historical dwarves
	if ( unit.race == dwarfRace ) then
		if (unit.sex ~= 0) then
			unit.name.first_name = firstnamepart[math.random(#firstnamepart)]..male_secondpart[math.random(#male_secondpart)];
		else
			unit.name.first_name = firstnamepart[math.random(#firstnamepart)]..female_secondpart[math.random(#female_secondpart)];
		end
	end
end
for index,unit in pairs(df.global.world.units.all) do --Renaming pretty much everyone else
	if ( unit.race == dwarfRace ) then
		if unit.flags1.important_historical_figure or unit.flags2.important_historical_figure then
			--Use the same name as the histfig data
			unit.name.first_name = df.historical_figure.find(unit.hist_figure_id).name.first_name;
		else
			if (unit.sex ~= 0) then
				unit.name.first_name = firstnamepart[math.random(#firstnamepart)]..male_secondpart[math.random(#male_secondpart)];
			else
				unit.name.first_name = firstnamepart[math.random(#firstnamepart)]..female_secondpart[math.random(#female_secondpart)];
			end
		end
	end
end
print("firstnamepart: "..#firstnamepart.."\nfemale: "..#female_secondpart.."\nmale: "..#male_secondpart);

Adventure mode

Item material changer

Roughly equivalent to changeitem m, but works better in adventure mode.

local r=nil
local top=dfhack.gui.getCurViewscreen()
print(top.parent,top)
local cvstype=dfhack.gui.getFocusString(top)
print(dfhack.gui.getFocusString(top.parent).."/"..cvstype)
if cvstype=="dungeon_monsterstatus" then
	print("  inventory size: "..#top.inventory)
	print("  inventory_cursor: "..top.inventory_cursor)
	r=top.inventory[top.inventory_cursor].item
elseif cvstype=="item" then
	-- override getSelectedItem()'s default behaviour for containers
	r=top.item
else
	r=dfhack.gui.getSelectedItem()
end

if r then
	local m=...
	if not m then
		print("no material")
		return
	end

	r.mat_type=dfhack.matinfo.find(m).type
	r.mat_index=dfhack.matinfo.find(m).index
	r.flags.weight_computed=0

	printall(r)
end

Urbanizer

Converts all forest retreats to visitable towns.

for k,v in pairs(df.global.world.world_data.sites) do
	if v.type==4 then
		v.type=5
		print('Site #'..k..': '..dfhack.TranslateName(v.name)..', "'..dfhack.TranslateName(v.name,1)..'", converted to town.')
	end
end

General

HealUnit

Repairs all health issues except for syndromes and severed limbs.

local unit=dfhack.gui.getSelectedUnit()
if unit then
	print("Erasing wounds...")
	while #unit.body.wounds > 0 do
		unit.body.wounds:erase(#unit.body.wounds-1)
	end
	unit.body.wound_next_id=1

	print("Refilling blood...")
	unit.body.blood_count=unit.body.blood_max

	print("Resetting status flags...")

	-- for DFHack >= 0.34.11 r3
	unit.status2.limbs_stand_count=unit.status2.limbs_stand_max
	unit.status2.limbs_grasp_count=unit.status2.limbs_grasp_max
	-- for older versions, use these instead:
	--unit.status2.able_stand_impair=unit.status2.able_stand
	--unit.status2.able_grasp_impair=unit.status2.able_grasp

	unit.flags2.has_breaks=false
	unit.flags2.gutted=false
	unit.flags2.circulatory_spray=false
	unit.flags2.vision_good=true
	unit.flags2.vision_damaged=false
	unit.flags2.vision_missing=false
	unit.flags2.breathing_good=true
	unit.flags2.breathing_problem=false

	unit.flags2.calculated_nerves=false
	unit.flags2.calculated_bodyparts=false

	print("Resetting counters...")
	unit.counters.winded=0
	unit.counters.stunned=0
	unit.counters.unconscious=0
	unit.counters.webbed=0
	unit.counters.pain=0
	unit.counters.nausea=0
	unit.counters.dizziness=0

	unit.counters2.paralysis=0
	unit.counters2.fever=0
	unit.counters2.exhaustion=0
	unit.counters2.hunger_timer=0
	unit.counters2.thirst_timer=0
	unit.counters2.sleepiness_timer=0
	unit.counters2.vomit_timeout=0

end

GoodAsNew

Removes all wear from the selected item.

local r=nil
local top=dfhack.gui.getCurViewscreen()
print(top.parent,top)
local cvstype=dfhack.gui.getFocusString(top)
print(dfhack.gui.getFocusString(top.parent).."/"..cvstype)
if cvstype=="dungeon_monsterstatus" then
	print("  inventory size: "..#top.inventory)
	print("  inventory_cursor: "..top.inventory_cursor)
	r=top.inventory[top.inventory_cursor].item
else
	r=dfhack.gui.getSelectedItem()
end

if r then
	r.wear=0
	r.wear_timer=0
	printall(r)
end