Skip to content

Instantly share code, notes, and snippets.

Avatar

IndigoFenix IndigoFenix

View GitHub Profile
@IndigoFenix
IndigoFenix / druidism.lua
Last active Aug 29, 2015
Enables druidic reactions, which allow the taming and manipulation of animals.
View druidism.lua
-- Enables nature merit system and reactions that utilize nature merit.
--[[
--New system:
effectiveskill(for taming) = skill
respectvalue = ((skill*5)^2)
interestvalue = merit/10
floor((1-((petvalue/2)/respectvalue))*100) = prob of success in a respect conflict
same thing with interestvalue to determine likelihood of taming
@IndigoFenix
IndigoFenix / creature_sscc_examples
Last active Sep 22, 2015
Enables soul manipulation and constructing creatures in reactions.
View creature_sscc_examples
creature_sscc_examples
[OBJECT:CREATURE]
Special classes for use with the SoulShuffle and ConstructCreature scripts:
DFHACK_CONSTRUCTCREATURE_CASTECOLORS - Uses the caste color system to make creatures show up with the color of their construction material. See below.
DFHACK_CONSTRUCTCREATURE_ITEMCORPSE - Causes the creature's itemcorpse to take on the same material as its first defined material.
DFHACK_SOULSHUFFLE_SCUTTLE_ON_REMOVAL - The creature will die when its soul is removed.
DFHACK_SOULSHUFFLE_VANISH_ON_REMOVAL - The creature will vanish into smoke when its soul is removed.
@IndigoFenix
IndigoFenix / ghostly.lua
Last active Aug 29, 2015
Turns a selected unit into a ghost and back again. Works in adventure mode too!
View ghostly.lua
--Turn ghost on or off
local unit=dfhack.gui.getSelectedUnit()
if unit == nil then
unit = df.unit.find(df.global.ui_advmode.player_id)
end
if unit then
if unit.flags1.dead then
@IndigoFenix
IndigoFenix / timestream.lua
Last active Sep 4, 2020
Multiplies the speed of calendar time by the specified value.
View timestream.lua
-- Multiplies the speed of calendar time by the specified value. The parameter can be any positive number, though going over 10 is likely to cause bugs. 1 is normal speed.
args={...}
local rate=tonumber(args[1])
local prev_tick = 0
if rate == nil then
rate = 1
elseif rate < 0 then
rate = 0
end
@IndigoFenix
IndigoFenix / add-exp.lua
Last active Aug 29, 2015
Adds a set amount of experience in a particular skill to a unit.
View add-exp.lua
--Gives a unit a certain amount of experience in a certain skill, leveling them up as appropriate. Intended for autosyndrome. Params: Unit id, skill name, exp. amount, max level (20 by default).
local args = {...}
local ok = true
--local unit=dfhack.gui.getSelectedUnit()
local unit = df.unit.find(tonumber(args[1]))
local skillname = args[2]
local amount = args[3]
local maxlevel = args[4]
if maxlevel == nil then maxlevel = 20 end
@IndigoFenix
IndigoFenix / hfspit.lua
Last active Aug 29, 2015
Creates a pit under the target leading straight to the Underworld.
View hfspit.lua
---Creates a pit under the target leading straight to the Underworld. Type '?' for help.
args={...}
if args[1] == '?' then
print("First parameter is target unit id, or 0 to select a location with the cursor.\n Second parameter is size of the pit in all directions.\n Third parameter is 1 to wall off the sides of the pit on all layers except the underworld, or anything else to leave them open. (Leaving them open may allow flying cave-dwellers to path to your fortress if you have normal access to the caverns)\n Fourth parameter is 1 to add stairs. Note that stairs are a bit buggy, as they will not reveal the bottom until you dig somewhere, but will still allow underworld creatures to path to your fortress.")
return
end
if args[1] ~= nil then
View construct-creature.lua
-- Uses a reaction to spawn a living creature that uses the materials of the reagents as body components. Reactions must begin with LUA_HOOK_CONSTRUCTCREATURE
--[[
You can have as many reagents as you like.
Reagents starting with USE will replace materials used in the creature, in the order that they are defined.
Make sure that each USE reagent consists of one item only. Otherwise, the second item taken will be counted as the second material.
Using tools as intermediary reagents is probably your best option for expensive creatures.
The product field determines the creature produced, where the material is CREATURE_MAT:(your creature):NONE. The probability should be set at 0 to avoid actually creating a boulder.
If you want to select a specific caste, the product field should have a PRODUCT_DIMENSION for the caste.
However, to make the creature's color show up based on its material, the creature must have 16 castes, one for each color.
@IndigoFenix
IndigoFenix / exile.lua
Last active May 1, 2019
Sends units away into the wild. Options include fort members, pets, wild animals, invaders, merchants, and diplomats. Can select one or all units. Exiled units will attempt to leave the map.
View exile.lua
-- Sends units away into the wild
args={...}
local targetUnit=dfhack.gui.getSelectedUnit()
if targetUnit == nil and args[2] ~= 'all' then
local targetUnit = df.unit.find(tonumber(args[2]))
end
group = args[1]
@IndigoFenix
IndigoFenix / slam.lua
Last active Jan 4, 2016
Slam a unit into the ground.
View slam.lua
-- Slam a unit into the ground
args={...}
local unit=dfhack.gui.getSelectedUnit()
if unit == nil then
local unit = df.unit.find(tonumber(args[2]))
end
local strength=args[1]
if unit == nil then
You can’t perform that action at this time.