View unMount.lua
function unMount (rider,horse)
--for k,horse in pairs(unit_list) do
--if unit_rider.pos.x==horse.pos.x and unit_rider.pos.y==horse.pos.y
--and unit_rider.pos.z==horse.pos.z then --check if they are on the same tile
for i=#horse.general_refs-1,0,-1 do
if df.general_ref_unit_riderst:is_instance(horse.general_refs[i]) then horse.general_refs:erase(i) end
end
rider.relations.rider_mount_id=-1
rider.flags1.rider=false
horse.flags1.ridden=false
View itemsyndrome.lua
-- Checks for inventory changes and applies or removes syndromes that items or their materials have. Use "disable" (minus quotes) to disable and "help" to get help.
local args = {...}
local function printItemSyndromeHelp()
print("Arguments (non case-sensitive):")
print(' "help": displays this dialogue.')
print(" ")
print(' "disable": disables the script.')
print(" ")
View projectileExpansion.lua
-- Adds extra functionality to projectiles. Use the argument "disable" (minus quotes) to disable.
flowtypes = {
miasma = 0,
mist = 1,
mist2 = 2,
dust = 3,
lavaMist = 4,
smoke = 5,
dragonFire = 6,
View moddableGods.lua
-- Sets player-defined gods to correct civilizations.
--[[Here's an example of how to make a god:
[CREATURE:SHEOGORATH]
[DOES_NOT_EXIST]
[MALE]
[NAME:jovial man:Daedra:madness] "Sheogorath, madness god." "Often depicted as a jovial man"
[CASTE_NAME:Sheogorath:Sheogorath:Sheogorath]
[DESCRIPTION:The Daedric Prince of madness.]
View force.lua
-- Forces an event.
local function findCiv(arg)
local entities = df.global.world.entities.all
if tonumber(arg) then return arg end
if arg and not tonumber(arg) then
for eid,entity in ipairs(entities) do
if entity.entity_raw.code == arg then return entity end
end
end
View SpawnUnitR3.lua
--create unit at pointer or given location. Usage e.g. "spawnunit DWARF 0 Dwarfy"
--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
args={...}
function getCaste(race_id,caste_id)
local cr=df.creature_raw.find(race_id)
return cr.caste[caste_id]
View Dragon Ball init.lua
local function getSuperSaiyanLevel(saiyan)
--15 is combathardness
if df.creature_raw.find(saiyan.race).creature_id~="SAIYAN" then return 0 end
local combatHardness=dfhack.units.getMiscTrait(saiyan,15,true).value --creates the misc trait if the saiyan doesn't have it yet
return (combatHardness>99) and 3 or (combatHardness>64) and 2 or (combatHardness>31) and 1 or 0 --return (x>y) and x or y is syntactically equivalent to, say, z = (x>y) : x ? y; return z; in C++.
end
local function superSaiyanGodSyndrome()
for syn_id,syndrome in ipairs(df.global.world.raws.syndromes.all) do
if syndrome.syn_name == "Super Saiyan God" then return syn_id end
View instant_transmission.lua
-- Allows instant transmission.
if df.global.gamemode~=1 then
qerror("Adventure mode only (for now). Sorry!")
end
function getTileType(x,y,z)
local block = dfhack.maps.getTileBlock(x,y,z)
if block then
return block.tiletype[x%16][y%16]
View shapechange.lua
-- transforms unit (by number) into another creature, choice given to user. Syntax is: unitID tickamount maxsize namefilter. A size of 0 is ignored. A length of 0 is also ignored. If no filter, all units will be sorted. A filter of ALL will also work with all units.
local dialog = require('gui.dialogs')
local script = require('gui.script')
function transform(target,race,caste,length)
if target==nil then
qerror("Not a valid target")
end
local defaultRace = target.enemy.normal_race
local defaultCaste = target.enemy.normal_caste
View take-slave.lua
-- Takes slaves. Hooks reactions that start with LUA_HOOK_TAKE_SLAVE. Copied very much from hire-guard.lua: http://dffd.wimbli.com/file.php?id=7785
--[[
sample reaction
[REACTION:LUA_HOOK_TAKE_SLAVE_DROW]
[NAME:Take someone ]
[BUILDING:TANNER:NONE]
[REAGENT:A:10000:COIN:NONE:INORGANIC:GOLD]
[PRODUCT:10:0:BOULDER:NONE:INORGANIC:CLAY][PRODUCT_DIMENSION:10]
[SKILL:TANNER]