This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--a library for creation and modification of jobs | |
--TODO: workshop jobs/reactions and building specific jobs in general | |
local _ENV = mkmodule('hack.scripts.jobs') | |
local buildings = require('dfhack.buildings') | |
local tile_attrs = df.tiletype.attrs | |
--[=[ helper functions ]=] | |
local function findRef(vector,ref_type) | |
for k,v in ipairs(vector) do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--heal unit from all wounds and damage | |
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 | |
for i=#unit.body.wounds-1,0,-1 do |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--create unit at pointer or given location and with given civ (usefull to pass -1 for enemy). Usage e.g. "spawnunit DWARF 0 Dwarfy" | |
--[=[ | |
Creature (ID), caste (number), name, x,y,z , civ_id(-1 for enemy, optional) for spawn. | |
Made by warmist, but edited by Putnam for the dragon ball mod to be used in reactions | |
note that it's extensible to any autosyndrome reaction to spawn anything due to this; to use in autosyndrome, you want \COMMAND spawnunit CREATURE caste_number name \LOCATION | |
TODO: | |
birth time | |
death time | |
real body size | |
blood max |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--removes heart | |
function findBodyPart(caste_raw,token) | |
for id,bp in ipairs(caste_raw.body_info.body_parts) do | |
if bp.token==token then | |
return id,bp | |
end | |
end | |
end | |
local trg=dfhack.gui.getSelectedUnit() | |
local heart_id=findBodyPart(df.creature_raw.find(trg.race).caste[trg.caste],"HEART") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--prints enum values | |
local args={...} | |
function isEnum(t) | |
return t._kind=='enum-type' | |
end | |
function printEnum(t) | |
if not isEnum(t) then | |
qerror("type is not an enum") | |
end | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local G=_G | |
local _ENV={} | |
name="Spatter" | |
raws_list={"building_spatter.txt","reaction_spatter.txt"} | |
patch_entity=[[ | |
[PERMITTED_REACTION:SPATTER_ADD_WEAPON_EXTRACT] | |
[PERMITTED_REACTION:SPATTER_ADD_AMMO_EXTRACT] | |
]] | |
patch_files={ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
--installs a modpack | |
-- args: modpack_name [-i|install|-if] [-u|uninstall] [entity_to_patch] | |
args={...} | |
if args[1]==nil or #args<2 then | |
print("Usage: modpack_name [-i|install|-if] [-u|uninstall] [entity_to_patch]") | |
end | |
local modPath=dfhack.getDFPath()..'/mods/'..args[1]..'/' | |
local dfMod=dofile(modPath..'init.lua') | |
local name=dfMod.name |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local G=_G | |
local _ENV={} | |
name="Mechanical Workshops" | |
raws_list={"building_dragon_engine.txt"} | |
patch_entity=[[ | |
[PERMITTED_BUILDING:DRAGON_ENGINE_S] | |
[PERMITTED_BUILDING:DRAGON_ENGINE_E] | |
[PERMITTED_BUILDING:DRAGON_ENGINE_W] | |
[PERMITTED_BUILDING:DRAGON_ENGINE_N] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function loopFix() | |
dofile('hack/scripts/fix/population-cap.lua') | |
dfhack.timeout(3,'months',loopFix) | |
end | |
loopFix() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
local ev=require("plugins.eventful") | |
local freq={[1]=10,[2]=5,[3]=500,[4]=1000,[5]=500,[6]=100,[7]=1,[8]=1000} | |
for k,v in pairs(freq) do | |
ev.enableEvent(k,v) | |
end | |
ev.onBuildingCreatedDestroyed.one=function(id) print("building cr/d:",id) end | |
ev.onConstructionCreatedDestroyed.one=function(id) print("construct cr/d:",id) end | |
ev.onJobInitiated.one=function(job) print("job init:",job) end | |
ev.onJobCompleted.one=function(job) print("job complete :",job) end | |
ev.onUnitDeath.one=function(id) print("death:",id) end |