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
-- Allows for script-based wishing. | |
function getGenderString(gender) | |
local genderStr | |
if gender==0 then | |
genderStr=string.char(12) | |
elseif gender==1 then | |
genderStr=string.char(11) | |
else | |
return "" |
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
-- Allows skills to activate lua scripts. | |
--[[Example usage: | |
...syndrome stuff... | |
[SYN_CLASS:\COMMAND][SYN_CLASS:skillroll][SYN_CLASS:\WORKER_ID] For autoSyndrome/syndromeTrigger. | |
[SYN_CLASS:MELEE_COMBAT] Can use any skill. | |
[SYN_CLASS:20] Rolls d20. Skill will be weighted to this value. | |
[SYN_CLASS:DICEROLL_1] If diceroll ends up as one... | |
[SYN_CLASS:kill][SYN_CLASS:\SKILL_UNIT_ID] Theoretical kill-given-unit-id command; slayrace doesn't do so. | |
[SYN_CLASS:DICEROLL_10] If diceroll is between 1 and 10 (2-10, inclusive)... |
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
-- 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:") | |
print(' "help": displays this dialogue.') | |
print(" ") | |
print(' "disable": disables the script.') | |
print(" ") |
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. 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={...} | |
local rando=dfhack.random.new() |
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 function teleport(unit,pos) | |
local unitoccupancy = dfhack.maps.getTileBlock(unit.pos).occupancy[unit.pos.x%16][unit.pos.y%16] | |
unit.pos.x = pos.x | |
unit.pos.y = pos.y | |
unit.pos.z = pos.z | |
if not unit.flags1.on_ground then unitoccupancy.unit = false else unitoccupancy.unit_grounded = false end | |
end | |
local function getArgsTogether(args) | |
local settings={ |
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
-- 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] |
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
-- 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 |
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
-- 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] |
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 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 |
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. 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] |