Advertisement
Guest User

Untitled

a guest
May 28th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.89 KB | None | 0 0
  1. function jump(unitSource,unitTarget)
  2.  
  3. local curpos
  4. if df.global.ui_advmode.menu==1 then
  5. curpos=df.global.cursor
  6. else
  7. print ("No cursor located! You would have slammed into the ground and exploded.")
  8. return
  9. end
  10.  
  11.  
  12. local count=0
  13. local l = df.global.world.proj_list
  14. local lastlist=l
  15. l=l.next
  16. while l do
  17. count=count+1
  18. if l.next==nil then
  19. lastlist=l
  20. end
  21. l = l.next
  22. end
  23.  
  24. resultx = curpos.x - unitSource.pos.x
  25. resulty = curpos.y - unitSource.pos.y
  26. resultz = curpos.z - unitSource.pos.z
  27.  
  28.  
  29. newlist = df.proj_list_link:new()
  30. lastlist.next=newlist
  31. newlist.prev=lastlist
  32. proj = df.proj_unitst:new()
  33. newlist.item=proj
  34. proj.link=newlist
  35. proj.id=df.global.proj_next_id
  36. df.global.proj_next_id=df.global.proj_next_id+1
  37. proj.unit=unitSource
  38. proj.origin_pos.x=unitSource.pos.x
  39. proj.origin_pos.y=unitSource.pos.y
  40. proj.origin_pos.z=unitSource.pos.z
  41. proj.target_pos.x=curpos.x
  42. proj.target_pos.y=curpos.y
  43. proj.target_pos.z=curpos.z
  44. proj.prev_pos.x=unitSource.pos.x
  45. proj.prev_pos.y=unitSource.pos.y
  46. proj.prev_pos.z=unitSource.pos.z
  47. proj.cur_pos.x=unitSource.pos.x
  48. proj.cur_pos.y=unitSource.pos.y
  49. proj.cur_pos.z=unitSource.pos.z
  50. proj.flags.no_impact_destroy=true
  51. proj.flags.piercing=true
  52. proj.flags.high_flying=true
  53. proj.flags.parabolic=true
  54. proj.flags.no_collide=false
  55. proj.flags.unk9=true
  56. proj.speed_x=resultx*10000
  57. proj.speed_y=resulty*10000
  58. proj.speed_z=resultz*10000
  59. unitoccupancy = dfhack.maps.ensureTileBlock(unitSource.pos).occupancy[unitSource.pos.x%16][unitSource.pos.y%16]
  60. if not unitSource.flags1.on_ground then
  61. unitoccupancy.unit = false
  62. else
  63. unitoccupancy.unit_grounded = false
  64. end
  65. unitSource.flags1.projectile=true
  66. unitSource.flags1.on_ground=false
  67. end
  68.  
  69. unitTarget = curpos
  70. if df.global.world.units.active[0].job.hunt_target==nil then
  71. unitSource = df.global.world.units.active[0]
  72. else
  73. unitSource = df.global.world.units.active[0].job.hunt_target
  74. end
  75.  
  76. jump(unitSource,unitTarget)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement