Skip to content

Instantly share code, notes, and snippets.

View warmist's full-sized avatar
๐Ÿ•น๏ธ

Warmist warmist

๐Ÿ•น๏ธ
View GitHub Profile
@warmist
warmist / test.lua
Created September 25, 2012 07:51
reactionhooks
b=require "plugins.reactionhooks"
b.onReactionComplete.foo=function (unit,in_items,out_items,call_native)
print("OKAY!")
printall(unit)
printall(in_items)
printall(out_items)
printall(call_native)
call_native=false
end
@warmist
warmist / todo.md
Last active February 25, 2016 11:01
DF todo
  1. gods in df -> moved to word doc
  2. figure out book interactions, give some fun stuff to random books (e.g. paralysis)
  3. finish unit creation script- mostly done, needs some minor fixes do it in c++
  4. site creation done, could use some more love.
  5. finish the lua-scripted reactions (including the god worshiping mini-mod, altars (with statue req) and mini altars with figurines?) done- eventful
  6. genetic engineering by adding generated creature raws
  7. jobs in adv mode (esp. build/dig) - almost done advfort
  8. anti-quantum stockpile mod
  9. Df achievements and stats(longest toss, most hurt unit, cheapest artifact). Per world and could be added to fortmode/advmode/legends menu
  10. maybe it's possible to add rust (new material that sometimes adds wear to item and a layer of rust/patina, maybe it inhibits later additions)
@warmist
warmist / synd.lua
Created November 12, 2012 21:17
Syndrome stuff
local d = require('gui.dialogs')
function assignSyndrome(target,syn_id)
if target==nil then
qerror("Not a valid target")
end
local ns=df.unit_syndrome:new()
local trg_syn=df.syndrome.find(syn_id)
ns.type=trg_syn.id
--ns.year=
--ns.year_time=
@warmist
warmist / vmethods.rst
Last active June 22, 2022 16:32
DF usefull vmethods.
Items:
  • incrementRotTimer
  • addImprovementFromJob
  • moveToGround
  • categorize
  • addWear/incWearTimer/setWear
  • addContaminant/removeContaminant/removeContaminantByIdx
  • contaminateWound
  • coverWithContaminant
  • becomePaste/becomePressed
@warmist
warmist / MakeSite.lua
Created November 25, 2012 00:08
Make site
function addSiteAtPos(x,y,rgn_x,rgn_y)
rgn_x=rgn_x or math.random(1,15)
rgn_y=rgn_y or math.random(1,15)
--[=[
<angavrilov> global = pos*16 + rgn
<angavrilov> BUT
<angavrilov> for cities global is usually 17x17, i.e. max size
<angavrilov> while rgn designates a small bit in the middle
<angavrilov> for stuff like forts that formula holds exactly
]=]--
@warmist
warmist / jobs.lua
Created November 26, 2012 20:50
job creation
function getLastJobLink()
local st=df.global.world.job_list
while st.next~=nil do
st=st.next
end
return st
end
function AddNewJob(job)
local nn=getLastJobLink()
local nl=df.job_list_link:new()
@warmist
warmist / realtime.lua
Created November 29, 2012 09:57
spam turn passes.
--passes turns constantly
gui=require ("gui")
realtime=defclass(realtime,gui.Screen)
function realtime:onRenderBody(dc)
self:sendInputToParent("A_WAIT")
self:renderParent()
end
function realtime:onIdle()
self._native.parent:logic()
@warmist
warmist / tofort.lua
Last active June 10, 2022 13:47
Switch to fort mode
-- changes from advmode to fort safely (hopefully)
if df.global.gamemode==df.game_mode.ADVENTURE then
local adv=df.global.world.units.active[0]
local ui=df.global.ui
function advGlobalPos()
local wd=df.global.world.world_data
return wd.adv_region_x*16+wd.adv_emb_x,wd.adv_region_y*16+wd.adv_emb_y
end
function inSite()
local tx,ty=advGlobalPos()
--create unit at pointer. Usage e.g. "spawnunit DWARF 0 Dwarfy"
args={...}
function getCaste(race_id,caste_id)
local cr=df.creature_raw.find(race_id)
return cr.caste[caste_id]
end
function genBodyModifier(body_app_mod)
local a=math.random(0,#body_app_mod.ranges-2)
return math.random(body_app_mod.ranges[a],body_app_mod.ranges[a+1])
end
{name="corpse explosion",f=function (unit_list,pos)
local items={}
for _,checked_item in pairs(df.global.world.items.other.ANY_CORPSE) do --actually you could iterate over only corpse pieces... But i'm too lazy
if checked_item.flags.on_ground then --add/remove more checks before then if you want to explode not ALL the corpses
table.insert(items,checked_item) --add to the list of target items
end
end
if #items==0 then
print"no corpses"