Skip to content

Commit 501faae

Browse files
committed
Import scripts from maxthyme-scripts
1 parent 2832de3 commit 501faae

3 files changed

Lines changed: 574 additions & 0 deletions

File tree

launch.lua

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
-- Activate with a cursor on screen and you will go there rapidly, attack something first to send them there.
2+
-- Based on propel.lua by Roses, molested by Rumrusher and I until this happened, sorry.
3+
--[[=begin
4+
5+
launch
6+
======
7+
Activate with a cursor on screen and you will go there rapidly, attack
8+
something first to send them there.
9+
10+
=end]]
11+
function launch(unitSource,unitTarget)
12+
local curpos
13+
if df.global.ui_advmode.menu==1 then
14+
curpos=df.global.cursor
15+
else
16+
print ("No cursor located! You would have slammed into the ground and exploded.") --seriously, kasplut!
17+
return
18+
end
19+
20+
21+
local count=0
22+
local l = df.global.world.proj_list
23+
local lastlist=l
24+
l=l.next
25+
while l do
26+
count=count+1
27+
if l.next==nil then
28+
lastlist=l
29+
end
30+
l = l.next
31+
end
32+
33+
resultx = curpos.x - unitSource.pos.x
34+
resulty = curpos.y - unitSource.pos.y
35+
resultz = curpos.z - unitSource.pos.z
36+
37+
38+
newlist = df.proj_list_link:new()
39+
lastlist.next=newlist
40+
newlist.prev=lastlist
41+
proj = df.proj_unitst:new()
42+
newlist.item=proj
43+
proj.link=newlist
44+
proj.id=df.global.proj_next_id
45+
df.global.proj_next_id=df.global.proj_next_id+1
46+
proj.unit=unitSource
47+
proj.origin_pos.x=unitSource.pos.x
48+
proj.origin_pos.y=unitSource.pos.y
49+
proj.origin_pos.z=unitSource.pos.z
50+
proj.target_pos.x=curpos.x
51+
proj.target_pos.y=curpos.y
52+
proj.target_pos.z=curpos.z
53+
proj.prev_pos.x=unitSource.pos.x
54+
proj.prev_pos.y=unitSource.pos.y
55+
proj.prev_pos.z=unitSource.pos.z
56+
proj.cur_pos.x=unitSource.pos.x
57+
proj.cur_pos.y=unitSource.pos.y
58+
proj.cur_pos.z=unitSource.pos.z
59+
proj.flags.no_impact_destroy=true
60+
proj.flags.piercing=true
61+
proj.flags.high_flying=true --this probably doesn't do anything, let me know if you figure out what it is
62+
proj.flags.parabolic=true
63+
proj.flags.no_collide=true
64+
proj.flags.unk9=true
65+
proj.speed_x=resultx*10000
66+
proj.speed_y=resulty*10000
67+
proj.speed_z=resultz*12500 --higher z speed makes it easier to reach a target safely
68+
if df.global.world.units.active[0].job.hunt_target==nil then
69+
proj.flags[12]=true
70+
elseif df.global.world.units.active[0].job.hunt_target then
71+
proj.flags[12]=false
72+
end
73+
unitoccupancy = dfhack.maps.ensureTileBlock(unitSource.pos).occupancy[unitSource.pos.x%16][unitSource.pos.y%16]
74+
if not unitSource.flags1.on_ground then
75+
unitoccupancy.unit = false
76+
else
77+
unitoccupancy.unit_grounded = false
78+
end
79+
unitSource.flags1.projectile=true
80+
unitSource.flags1.on_ground=false
81+
end
82+
83+
unitTarget = curpos
84+
if df.global.world.units.active[0].job.hunt_target==nil then
85+
unitSource = df.global.world.units.active[0]
86+
else
87+
unitSource = df.global.world.units.active[0].job.hunt_target --kudos Rumrusher for including this, allowing you to fling others around!
88+
end
89+
90+
launch(unitSource,unitTarget)

names.lua

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
--rename items or units
2+
--[[=begin
3+
4+
names
5+
=====
6+
Rename units or items. Usage:
7+
8+
:-help: print this help message
9+
:-item: if viewing an item
10+
:-unit: if viewing a unit
11+
:-first [Somename | "Some Names like This":
12+
if a first name is desired, leave blank to clear current first name
13+
=end]]
14+
local utils = require 'utils'
15+
16+
validArgs = validArgs or utils.invert({
17+
'help',
18+
'item',
19+
'unit',
20+
'first'
21+
})
22+
23+
local args = utils.processArgs({...}, validArgs)
24+
25+
if args.help then
26+
print(
27+
[[names.lua
28+
arguments:
29+
-help
30+
print this help message
31+
-item
32+
if viewing an item
33+
-unit
34+
if viewing a unit
35+
-first Somename or "Some Names like This"
36+
if a first name is desired, leave blank to clear current first name
37+
]])
38+
return
39+
end
40+
41+
if not df.viewscreen_layer_choose_language_namest:is_instance(dfhack.gui.getCurViewscreen()) then
42+
choices = df.new(df.viewscreen_setupadventurest) ; choices.subscreen = 3 ; gui = require 'gui' ; gui.simulateInput(choices, 'A_RANDOM_NAME') ; gui.simulateInput(choices, 'A_CUST_NAME')
43+
end
44+
45+
if args.item then
46+
fact = dfhack.gui.getCurViewscreen().parent.item.general_refs[0].artifact_id
47+
trg = df.artifact_record.find(fact)
48+
end
49+
50+
if args.unit then
51+
trg = dfhack.gui.getCurViewscreen().parent.unit
52+
end
53+
54+
if args.first then
55+
trg.name.first_name = args.first
56+
end
57+
58+
function newName()
59+
newn = dfhack.gui.getCurViewscreen().name
60+
oldn = trg.name
61+
for k = 0,6 do
62+
oldn.words[k] = newn.words[k]
63+
oldn.parts_of_speech[k] = newn.parts_of_speech[k]
64+
end
65+
oldn.language = newn.language
66+
oldn.has_name = newn.has_name
67+
end
68+
newName()

0 commit comments

Comments
 (0)