Skip to content

Instantly share code, notes, and snippets.

@Rumrusher
Created May 4, 2016 18:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Rumrusher/a8f1bfefa2fbed450b6d63f6739b2562 to your computer and use it in GitHub Desktop.
Save Rumrusher/a8f1bfefa2fbed450b6d63f6739b2562 to your computer and use it in GitHub Desktop.
started as a Jump code Max and I co-created from the propel.lua from rose scripts now modified to now only throw items around. uses warmists get creature at xyz functions
function telekinesis(itemSource,itemTarget)
local curpos
if df.global.ui_advmode.menu==1 then
curpos=df.global.cursor
else
print ("No cursor located! uhh wouldn't had effected anything though.")
return
end
local count=0
local l = df.global.world.proj_list
local lastlist=l
l=l.next
while l do
count=count+1
if l.next==nil then
lastlist=l
end
l = l.next
end
resultx = curpos.x - itemSource.pos.x
resulty = curpos.y - itemSource.pos.y
resultz = curpos.z - itemSource.pos.z
newlist = df.proj_list_link:new()
lastlist.next=newlist
newlist.prev=lastlist
proj = df.proj_itemst:new()
newlist.item=proj
proj.link=newlist
proj.id=df.global.proj_next_id
df.global.proj_next_id=df.global.proj_next_id+1
proj.item=itemSource
proj.origin_pos.x=itemSource.pos.x
proj.origin_pos.y=itemSource.pos.y
proj.origin_pos.z=itemSource.pos.z
proj.target_pos.x=curpos.x
proj.target_pos.y=curpos.y
proj.target_pos.z=curpos.z
proj.prev_pos.x=itemSource.pos.x
proj.prev_pos.y=itemSource.pos.y
proj.prev_pos.z=itemSource.pos.z
proj.cur_pos.x=itemSource.pos.x
proj.cur_pos.y=itemSource.pos.y
proj.cur_pos.z=itemSource.pos.z
proj.flags.no_impact_destroy=true
proj.flags.piercing=true
proj.flags.high_flying=truel;
proj.flags.parabolic=true
proj.flags.no_collide=false
proj.flags.unk9=true
proj.speed_x=resultx*10000
proj.speed_y=resulty*10000
proj.speed_z=resultz*10000
--[[unitoccupancy = dfhack.maps.ensureTileBlock(itemSource.pos).occupancy[itemSource.pos.x%16][itemSource.pos.y%16]
if not itemSource.flags1.on_ground then
unitoccupancy.unit = false
else
unitoccupancy.unit_grounded = false
end
itemSource.flags1.projectile=true
itemSource.flags1.on_ground=false]]--
end
function getxyz() -- this will return pointers x,y and z coordinates.
local x=df.global.cursor.x
local y=df.global.cursor.y
local z=df.global.cursor.z
return x,y,z -- return the coords
end
function getItemAtPos(x,y,z) -- gets the item index @ x,y,z coord
--local x,y,z=getxyz() --get 'X' coords
local vector=df.global.world.items.all -- load all items
for i = 0, #vector-1 do -- look into all items offsets
local curpos=vector[i].pos --get its coordinates
local cx=curpos.x
local cy=curpos.y
local cz=curpos.z
if cx==x and cy==y and cz==z then --compare them
return vector[i] --return index
end
end
--print("item not found!")
return nil
end
itemSource=getItemAtPos(getxyz())
test = dfhack.lineedit("")
itemTarget = curpos
telekinesis(itemSource,itemTarget)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment