Skip to content

Commit 63f5b03

Browse files
authored
Scripts for submission
Cleaned out some of the other stuff and fixed a few bugs I know of.
1 parent f08b1a3 commit 63f5b03

17 files changed

Lines changed: 1038 additions & 111 deletions

articrap.lua

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
--Like artifake but maybe with a little less of the shiny fancy stuff, might fall off truck once or six time, is good!
2+
--[====[
3+
articrap
4+
=====
5+
Changes the selected item or inventory full of items into artifact quality items which don't accumulate wear.
6+
]====]
7+
local scrn=dfhack.gui.getCurViewscreen()
8+
local articrap
9+
if df.viewscreen_itemst:is_instance(scrn) then
10+
articrap=scrn.item
11+
articrap.flags.artifact_mood=true
12+
articrap.flags.artifact=true
13+
articrap.quality=6
14+
articrap.wear=0
15+
articrap.wear_timer=0
16+
--[[play with these articrap.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=41,mat_index=3,quality=6,skill_rating=15})
17+
if you want bling articrap.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=420,mat_index=230,quality=6,skill_rating=15})]]
18+
articrap.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=0,mat_index=9,quality=6,skill_rating=15})
19+
if (df.item_weaponst:is_instance(articrap) or df.item_toolst:is_instance(articrap)) then articrap.sharpness=100000 end
20+
elseif df.viewscreen_dungeon_monsterstatusst:is_instance(scrn) then
21+
articrap=scrn.inventory
22+
for k,v in ipairs(articrap) do
23+
articrap[k].item.flags.artifact=true
24+
articrap[k].item.flags.artifact_mood=true
25+
articrap[k].item.quality=6
26+
articrap[k].item.wear=0
27+
articrap[k].item.wear_timer=0
28+
--[[play with these articrap.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=41,mat_index=3,quality=6,skill_rating=15})
29+
if you want bling articrap.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=420,mat_index=230,quality=6,skill_rating=15})]]
30+
articrap[k].item.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=0,mat_index=9,quality=6,skill_rating=15})
31+
if (df.item_weaponst:is_instance(articrap[k].item) or df.item_toolst:is_instance(articrap[k].item)) then articrap[k].item.sharpness=100000 end
32+
end
33+
elseif df.global.ui_advmode.menu==5 then
34+
articrap=df.global.world.units.active[0].inventory
35+
for k,v in ipairs(articrap) do
36+
articrap[k].item.flags.artifact=true
37+
articrap[k].item.flags.artifact_mood=true
38+
articrap[k].item.quality=6
39+
articrap[k].item.wear=0
40+
articrap[k].item.wear_timer=0
41+
--[[play with these articrap.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=41,mat_index=3,quality=6,skill_rating=15})
42+
if you want bling articrap.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=420,mat_index=230,quality=6,skill_rating=15})]]
43+
articrap[k].item.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=0,mat_index=9,quality=6,skill_rating=15})
44+
if (df.item_weaponst:is_instance(articrap[k].item) or df.item_toolst:is_instance(articrap[k].item)) then articrap[k].item.sharpness=100000 end
45+
end
46+
end

artifake.lua

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
-- You like artifact but no have artifact? Get artifake instead, just as good, is two more even!
2+
local utils = require 'utils'
3+
4+
validArgs = validArgs or utils.invert({
5+
'help',
6+
'material',
7+
'item',
8+
'name',
9+
'r',
10+
'l'
11+
})
12+
13+
local args = utils.processArgs({...}, validArgs)
14+
15+
if args.help then
16+
print(
17+
[[artifake.lua
18+
arguments:
19+
-help
20+
print this help message
21+
-material matstring
22+
specify the material of the item to be created
23+
examples:
24+
INORGANIC:IRON
25+
CREATURE_MAT:DWARF:BRAIN
26+
PLANT_MAT:MUSHROOM_HELMET_PLUMP:DRINK
27+
-item itemstring
28+
specify the itemdef of the item to be created
29+
examples:
30+
WEAPON:ITEM_WEAPON_PICK
31+
-name namestring
32+
specify a first name if desired
33+
-r
34+
for right handed gloves
35+
-l
36+
for left handed gloves
37+
]])
38+
return
39+
end
40+
41+
if dfhack.gui.getSelectedUnit(true) then
42+
args.creator = dfhack.gui.getSelectedUnit()
43+
else args.creator = df.global.world.units.active[0]
44+
end
45+
if not args.item then
46+
error 'Invalid item.'
47+
end
48+
local itemType = dfhack.items.findType(args.item)
49+
if itemType == -1 then
50+
error 'Invalid item.'
51+
end
52+
local itemSubtype = dfhack.items.findSubtype(args.item)
53+
54+
args.material = dfhack.matinfo.find(args.material)
55+
if not args.material then
56+
error 'Invalid material.'
57+
end
58+
59+
60+
local item = dfhack.items.createItem(itemType, itemSubtype, args.material['type'], args.material.index, args.creator)
61+
62+
local base=df.item.find(df.global.item_next_id-1)
63+
df.global.world.artifacts.all:new()
64+
df.global.world.artifacts.all:insert('#',{new=df.artifact_record})
65+
local facts = df.global.world.artifacts.all
66+
for _,k in ipairs(facts) do
67+
if k.item==nil then
68+
local fake=k
69+
fake.id=df.global.artifact_next_id
70+
fake.item = {new=base}
71+
fake.item.flags.artifact = false
72+
fake.item.flags.artifact_mood = true
73+
fake.item.id = base.id
74+
fake.item.general_refs:insert('#',{new =df.general_ref_is_artifactst})
75+
fake.item.general_refs[0].artifact_id = fake.id
76+
fake.item.spec_heat = base.spec_heat
77+
fake.item.ignite_point = base.ignite_point
78+
fake.item.heatdam_point = base.heatdam_point
79+
fake.item.colddam_point = base.colddam_point
80+
fake.item.boiling_point = base.boiling_point
81+
fake.item.fixed_temp = base.fixed_temp
82+
fake.item.weight = base.weight
83+
fake.item.weight_fraction = base.weight_fraction
84+
fake.item.improvements:insert('#',{new = df.itemimprovement_spikesst,mat_type=41,mat_index=3,quality=6,skill_rating=15})
85+
fake.item.improvements:insert('#',{new = df.itemimprovement_spikesst,mat_type=40,mat_index=3,quality=6,skill_rating=15})
86+
fake.item.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=43,mat_index=3,quality=6,skill_rating=15})
87+
fake.item.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=420,mat_index=230,quality=6,skill_rating=15})
88+
fake.item.improvements:insert('#',{new = df.itemimprovement_art_imagest,mat_type=0,mat_index=9,quality=6,skill_rating=15})
89+
fake.flags:new()
90+
for i = 0,7 do
91+
if #fake.flags < 8 then
92+
fake.flags[i] = true
93+
elseif #fake.flags==8 then
94+
fake.flags[0] = false
95+
fake.flags[i] = false
96+
end
97+
end
98+
fake.anon_1 = -1000000
99+
fake.anon_2 = -1000000
100+
fake.anon_3 = -1000000
101+
base.flags.artifact = false
102+
base.flags.artifact_mood = true
103+
base.general_refs = fake.item.general_refs
104+
base.improvements = fake.item.improvements
105+
fake.item:setQuality(6)
106+
base:setQuality(6)
107+
if (df.item_weaponst:is_instance(fake.item) or df.item_toolst:is_instance(fake.item)) then fake.item.sharpness=100000 end
108+
if (df.item_weaponst:is_instance(base) or df.item_toolst:is_instance(base)) then base.sharpness=100000 end
109+
df.global.artifact_next_id=df.global.artifact_next_id+1
110+
df.global.world.history.events:new()
111+
df.global.world.history.events:insert('#',{new=df.history_event_artifact_createdst,
112+
year = df.global.cur_year,
113+
seconds = df.global.cur_year_tick_advmode,
114+
id = df.global.hist_event_next_id,
115+
artifact_id = fake.id,
116+
unit_id = args.creator.id,
117+
hfid = args.creator.hist_figure_id,
118+
}
119+
)
120+
df.global.hist_event_next_id = df.global.hist_event_next_id+1
121+
if args.r then
122+
base.handedness[0] = true
123+
fake.item.handedness[0] = true
124+
end
125+
if args.l then
126+
base.handedness[1] = true
127+
fake.item.handedness[1] = true
128+
end
129+
if args.name then do
130+
fake.name.first_name = args.name
131+
fake.name.language = 0
132+
fake.name.has_name = true
133+
end
134+
end
135+
end
136+
end

assumecontrol.lua

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
--Assume Direct Control of the unit you're viewing. This Can Hurt You.
2+
local utils = require 'gui'
3+
local dialog = require 'gui.dialogs'
4+
5+
function assumeControl(new,old)
6+
local actold
7+
for i,j in ipairs(df.global.world.units.all) do
8+
if j.id==df.global.world.units.active[0].id then
9+
actold=j.id
10+
break
11+
end
12+
end
13+
local active=df.global.world.units.active
14+
local old
15+
old=df.unit.find(actold)
16+
local new
17+
new=dfhack.gui.getSelectedUnit(true)
18+
if new==nil then
19+
qerror("Unable to Assume Control!")
20+
end
21+
local actnew
22+
for k,v in pairs(active) do
23+
if v==new then
24+
actnew=k
25+
break
26+
end
27+
end
28+
if actnew==nil then
29+
qerror("Attempt to Assume Control has failed?")
30+
end
31+
if dfhack.gui.getSelectedUnit(true)==active[0] then
32+
local choices={}
33+
for k,v in pairs(active) do
34+
if dfhack.units.getNemesis(active[k]).flags.RETIRED_ADVENTURER==true then
35+
local nems=active[k]
36+
table.insert(choices,{text=nems.name.first_name,nems=k})
37+
end
38+
dialog.showListPrompt("Unit choice", "Choose unit to return to:", COLOR_WHITE,choices,
39+
function (idx,choice)
40+
dfhack.units.getNemesis(choice).flags.ACTIVE_ADVENTURER=true
41+
dfhack.units.getNemesis(choice).flags.ADVENTURER=true
42+
dfhack.units.getNemesis(choice).flags.RETIRED_ADVENTURER=false
43+
choice.status.current_soul.personality.flags[1]=true
44+
dfhack.units.getNemesis(old).flags.ACTIVE_ADVENTURER=false
45+
dfhack.units.getNemesis(old).flags.RETIRED_ADVENTURER=true
46+
old.status.current_soul.personality.flags[1]=false
47+
return
48+
end)
49+
end
50+
end
51+
active[actnew]=active[0]
52+
active[0]=new
53+
local target = dfhack.units.getNemesis(new)
54+
if target then
55+
local nwnem=dfhack.units.getNemesis(new)
56+
local olnem=dfhack.units.getNemesis(old)
57+
if olnem then
58+
olnem.flags.ACTIVE_ADVENTURER=false
59+
olnem.flags.RETIRED_ADVENTURER=true
60+
olnem.unit.status.current_soul.personality.flags[1]=false
61+
olnem.unit.idle_area.x=olnem.unit.pos.x
62+
olnem.unit.idle_area.y=olnem.unit.pos.y
63+
olnem.unit.idle_area.z=olnem.unit.pos.z
64+
end
65+
if nwnem then
66+
nwnem.flags.ACTIVE_ADVENTURER=true
67+
nwnem.flags.RETIRED_ADVENTURER=false
68+
nwnem.flags.ADVENTURER=true
69+
nwnem.unit.status.current_soul.personality.flags[1]=true
70+
for k,v in pairs(df.global.world.nemesis.all) do
71+
if v.id==nwnem.id then
72+
df.global.ui_advmode.player_id=k
73+
end
74+
end
75+
end
76+
else
77+
qerror("Assuming Direct Control! Current target may not last long!")
78+
end
79+
end
80+
assumeControl(new,old)

breakdance.lua

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
--Breaks up a stuck dance activity.
2+
local unit = df.global.world.units.active[0]
3+
local act = unit.social_activities[0]
4+
if df.activity_entry.find(act).type==8 then
5+
df.activity_entry.find(act).events[0].flags.dismissed = true
6+
end

cannibalism.lua

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
--Need to get rid of a body? Hope you're hungry, because you can eat the whole thing with this.
2+
local scrn=dfhack.gui.getCurViewscreen()
3+
local meat
4+
if df.viewscreen_itemst:is_instance(scrn) then
5+
meat=scrn.item
6+
meat.flags.dead_dwarf=false
7+
elseif df.viewscreen_dungeon_monsterstatusst:is_instance(scrn) then
8+
meat=scrn.inventory
9+
for k,v in ipairs(meat) do
10+
meat[k].item.flags.dead_dwarf=false
11+
end
12+
elseif df.global.ui_advmode.menu==5 then
13+
meat=df.global.world.units.active[0].inventory
14+
for k,v in ipairs(meat) do
15+
meat[k].item.flags.dead_dwarf=false
16+
end
17+
end

crithit.lua

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
--Turns the previously readied attack into a super powerful critical hit.
2+
local unit = df.global.world.units.active[0]
3+
local attks = unit.actions
4+
for k,v in ipairs(attks) do
5+
if attks[k].type==1 then
6+
attks[k].data.attack.attack_accuracy=1000
7+
attks[k].data.attack.attack_velocity=9999999
8+
end
9+
for i = 0,3 do
10+
unit.body.body_plan.attacks[i].velocity_modifier=2700000
11+
unit.body.body_plan.attacks[i].contact_perc=100000
12+
unit.body.body_plan.attacks[i].penetration_perc=100000
13+
unit.body.body_plan.attacks[i].flags.edge=true
14+
end
15+
end

fillneeds.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
--Use with a unit selected to make them focused and unstressed.
2+
local utils=require('utils')
3+
local args = utils.processArgs({...}, validArgs)
4+
5+
local unit = args.unit and df.unit.find(args.unit) or dfhack.gui.getSelectedUnit(true)
6+
7+
if not unit then qerror('A unit must be specified or selected.') end
8+
9+
function satisfyNeeds(unit,mind)
10+
local mind = unit.status.current_soul.personality.needs
11+
for k,v in ipairs(mind) do
12+
mind[k].focus_level = 400
13+
end
14+
unit.status.current_soul.personality.stress_level=-1000000
15+
end
16+
satisfyNeeds(unit,mind)

firestarter.lua

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
--Use while viewing an item, unit inventory, or tile to start fires.
2+
local tinder
3+
if dfhack.gui.getCurFocus() == 'item' then
4+
tinder=dfhack.gui.getCurViewscreen().item
5+
tinder.flags.on_fire=true
6+
elseif dfhack.gui.getSelectedUnit(true) then
7+
tinder=dfhack.gui.getSelectedUnit(true).inventory
8+
for k,v in ipairs(tinder) do
9+
tinder[k].item.flags.on_fire=true
10+
end
11+
elseif df.global.ui_advmode.menu==1 then
12+
local curpos=df.global.cursor
13+
df.global.world.fires:insert('#',{new=df.fire})
14+
local hot = df.global.world.fires
15+
for _,k in ipairs(hot) do
16+
if k.temperature==0 then
17+
local spot = k
18+
k.pos.x=curpos.x
19+
k.pos.y=curpos.y
20+
k.pos.z=curpos.z
21+
k.timer=1000
22+
k.temperature=60000
23+
end
24+
end
25+
end

flashstep.lua

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
--Teleports unit to cursor
2+
function flashstep(flash,step)
3+
local flash = df.global.world.units.active[0]
4+
local step
5+
if df.global.ui_advmode.menu == df.ui_advmode_menu.Look then
6+
step = df.global.cursor
7+
else
8+
qerror("No [l] cursor located! You kinda need it for this script.")
9+
end
10+
local unitoccupancy = dfhack.maps.getTileBlock(flash.pos).occupancy[flash.pos.x%16][flash.pos.y%16]
11+
flash.pos.x = step.x
12+
flash.pos.y = step.y
13+
flash.pos.z = step.z
14+
if flash.pos.x==step.x then
15+
local stepvisibility = dfhack.maps.getTileBlock(flash.pos).designation[flash.pos.x%16][flash.pos.y%16]
16+
stepvisibility.hidden=false
17+
end
18+
if not flash.flags1.on_ground then unitoccupancy.unit = false else unitoccupancy.unit_grounded = false end
19+
end
20+
flashstep(flash,step)

0 commit comments

Comments
 (0)